Expressions

 

(Click for Danish version)

 

Syntax

 

Expression

EVALUATES TO TRUE, IF ...

[varname].[label value]

... choice connected to the specific label value has been chosen on the scale/variable

[varname] IS NULL

... variable/question is empty/missing

NOT (Expression)

... expression in the parenthes is false

(Expression1) AND (Expression2)

... both expressions are true

(Expression1) OR (Expression2)

... either Expression1 or Expression2 is true

[varname]  <, <=, >, >=, =  X

... a numeric variable is less than, less than or equal to, greater than, greater than or equal to, equal to a specific value X

[varname1]  <, <=, >, >=, =  [varname2]

... a numeric variable is less than, less than or equal to, greater than, greater than or equal to, equal to the value of another numeric variable

 

Functions

Comment

SUM([varname])

Takes the value 0, if the variable/question is empty/missing or a text-question, the label value for the chosen choice if the variable is a scale variable (if more than one choice are selected in a multiple choice question, the lowest label value is chosen) and the numeric value itself when the variable is a numeric variable

SUM([varname1], [varname2])

Equal to SUM([varname1]) + SUM([varname2])

[varname1]  +, -, /, *  number

Function that add, subtract, divide or multiply a numeric variable and a number. Notice that if the variable doesn't contain any value (i.e. empty/missing) the entire expression will be emty/missing

[varname1]  +, -, /, *  [varname2]

Function that add, subtract, divide or multiply numeric variables. Notice that if both variables doesn't contain numeric values (i.e. empty/missing) the entire expression will be emty/missing

SUM([varname1])  +, -, /, *  SUM([varname2])

Function used to add, subtract, divide or multiply variables. Can be used when one or more variables are scale variables or when on or more variables can be empty/missing. See SUM-function

AVERAGE ([varname1], [varname2])

Calculates the average of the two variables (numeric or scale variables). Variables with emty/missing values are excluded from the calculation. If all variables have emty/missing values the average will be empty/missing

COUNTCHECKED([varname])

Counts the number of selected choices in a scale variable/question. Returns empty/missing if the variable is not a scale variable

CHECKDEPEND([varname1].[label value], [varname2])

Evaluates to true if the choice connected to the specified label value in variabel 1 is selected and the open variable variable 2 is not empty/missing OR if the choice is not selected and the open variable is empty/missing

iif(Expression, Value1, Value2)

Function that returns the value Value1 if the Expression is true and Value2 if the expression is false

iif(Expression, [varname], Value)

Function that returns the value of the variable varname if the Expression is true and Value otherwise

 

 

Handling of empty/missing values in expressions

The expression [s02] > 10 doesn't make sense if s02 doesn't contain a value (is unanswered). The expression is neither true nor false.

 

In both activation and validation expression this is handled by ignoring the expression. The validation expression [s02] > 10 won't give an error even though s02 is unanswered. By the same logic an element with the activation expression [s02] > 10 will be activated if s02 is empty/missing. 

 

If you want another behaviour you will have to add AND NOT([s02] is NULL). Now the entire expression will be false if s02 is unanswered (empty/missing).

 

Another option is to use SUM([s02]) > 10. If s02 is unanswered SUM([s02]) will be 0 and the expression therefore false.

 

Activation expressions (A) - Examples

 

[s01].[2]

Element activated if the choice with label value 2 is selected on the scale variable s01. If s01 is unanswerede (empty/missing) the element isn't activated.

 

[s02] > 10 AND NOT([s02] IS NULL)

Element activated if the numeric variable s02 contains a value greater than 10. Element is not activated if s02 can is unanswered (NULL). Notice that the AND operator means that the element will only be activated if both parts of the expression are true.

 

([s01].[1] OR [s01].[2] OR [s01].[3]) AND [s02] >= 0

Element activated if the respondent has selected choice with label value 1, 2 or 3 in s01 and at the same time has filled-in a number greater than or equal to 0 in s02.

 

SUM([s03], [s04], [s05]) >= 100

Element activated if the sum of the numbers in s03, s04 and s05 is greater than or equal to 100. If one of the variables s03, s04 or s05 is unanswered (empty/missing) its value is set to 0 in the calculation.

 

AVERAGE([s06], [s07], [s08]) < 3

s06, s07 and s08 are 3 satisfaction questions with a 5-point scale (1=very unsatisfied, 2=unsatisfied, 3=neither/nor, 4=satisfied, 5=very satisfied). We want a new page in the questionnaire activated if the respondent on average is dissatisfied with the three questions - i.e. on average less than 3.

 

COUNTCHECKED([s09]) > 1

Element activated if the respondent has selected more than one of the choices in the multiple response question s09.

 

Validation expressions (V) - Examples

 

SUM([s01]) >= SUM([s02])

In s01 a company is asked to specify the total revenue. In s02 the company is asked to specify the revenue related to the Internet. The validation expression makes sure that it isn't possible to specify an internet related revenue greater than the total revenue.

 

CHECKDEPEND([s09].[7], [s10])

s09 is a scale variable where the 7. choice "Other" (label value 7) has an open text field s10 connected. We want to make sure that if choice 7 has been selected the open text variable must be filled out - and vice versa if choice 7 has not been selected, s10 should be empty.

 

References (E) - Examples

 

[s02]

Inserts the value of s02. Notice that this doesn't work with scale variables. Here you should use the IIF function described below or use the SUM or AVERAGE function to insert the label value.

 

IIF([sex].[1],"Sir ","Mrs ")

If the choice with value label 1 is selected the text Sir is returned. Otherwise the text Mrs is returned. References to other variables and IIF functions nested in other IIF functions can be used, making it possible to create complex expressions.