1. Home
2. Survey
3. Build Survey
4. Filter
5. Calculations and variables in Survalyzer (professional user)
1. Home
2. Survey
3. Build Survey
4. Question types
5. Value assignment (professional user)
6. Calculations and variables in Survalyzer (professional user)

# Calculations and variables in Survalyzer (professional user)

In Survalyzer you can use calculations in filters and value assignments, where you can also use variables. Variables and their names can be defined by question code.

Calculations

You can use calculations with variables in filters, validation conditions and value assignments. In calculations, you can use a comparison of two expressions. Both expressions can be numbers, as well as variables or calculations (with variables and numbers).

In the following example, we show the calculation of an average. A matrix question (q1) has three items (each with its own row) to be rated on a 5-point scale. If the respondent gives a low average rating, he/she is shown the next question. The filter condition of the next question checks the average rating of the three items:

Calculations can be made using the four basic arithmetic operations: addition (+), subtraction (-), multiplication (*), division (/) and modulus (%).

Modulo calculation means determining the remainder that remains after dividing the first number by the second. Example: 5%3 = 2 means: 2 is the remainder that is left after dividing ‘5 divided by 3’.

Brackets can be used to indicate operations that should be prioritised. Possible variables include: survey variables (question codes), sample or panel variables (sample/panel fields), URL variables (derived from URL parameters added to the survey link) and variables that can be used in calculations.

Note: In order to calculate an average value in a value assignment, you can use, for example, the following notation: (mean(q1_1,q1_2,q1_3,q1_4) + q2)/2. In this process, the mean of 4 services in question q1 is first determined. To this average, the result of the single-choice question q2 is added. The outcome of this has to be divided by 2 again.

Variables

Question variables use question codes, e.g. q1. If a question requires more than one variable (e.g. a multiple response or matrix question), answer options are added using variable choice codes. An underscore is by default placed between a question code and an answer option variable, e.g. q1_1, q1_2, q1_3. Text fields in half-open questions are completed with _text, e.g. q1_4_text. If you want to reflect the open answer given by a participant in a question, e.g. open-ended question, in another question, you can use such a question-placeholder.

Below, we explain how to find the correct variable for each of these question types:

Single response, drop-down, slider, open question

For these question types, the variable name can be easily found: the question code.

For all question types, the variable name will always be in the top left corner of the element (Build). This also applies to the E-mail and Date question types.

Explanation: QuestionCode
Value: ChoiceCode

Multiple response

In a multiple response question, each choice represents a variable that either has the value 0 (unchecked) or 1 (checked), depending on whether the answer was chosen by the respondent or not. The variable name is built up from a combination of question code and choice code.

So, for the first two choices, the variables would be:
Choice 1: q5_1
Choice 2: q5_2

Explanation: QuestionCode_ChoiceCode
Value: 0 (unchecked) or 1 (checked)

Standard matrix - Single response / Semantic differential

A standard matrix question containing one answer does not have column groups and is set as a single response question or as a drop-down. In this case, each row represents its own variable. The variable name is built up from a combination of question code and row code.

So, for the first two rows, this would result in the following variables:
Row 1: q6_1
Row 2: q6_2

Explanation: QuestionCode_RowCode
Value: ChoiceCode

Standard matrix - Multiple response

A standard matrix question containing multiple answers does not have column groups and is set as a multiple response question. In this case, one variable belongs to each option in each row. The variable name is built up from a combination of question code, row code and option code.

So, for the first two options in the first row, this would result in the following variables:
Option 1: q7_1_1.value
Option 2: q7_1_2.value

The first two options in the second row, would result in the following variables:
Option 1: q7_2_1.value
Option 2: q7_2_2.value

Explanation: QuestionCode_RowCode_ChoiceCode
Value: 0 (unchecked) or 1 (checked)

Matrix question with column groups

A column group adds a layer to the matrix question, resulting in an even longer variable name. Column groups are numbered, based on the order in which they appear in the user interface. The variable name is built up from a combination of question code, row code, column group number and option code.

The first two options in the first row of the first column group (with Multiple response) are then assigned the following variables:
Option 1: q7_1_1_1.value
Option 2: q7_1_1_2.value

Explanation: QuestionCode_RowCode_ColumnGroupNumber_ChoiceCode
Value: 0 (unchecked) or 1 (checked)

For the first two options in the first row of the second column group (with Single response), there would then be the following variable:
Option 1: q7_1_2 (title column)
OR
Option 2: q7_1_2.value (value column)

Explanation: QuestionCode_RowCode_ColumnGroupNumber

Rank order

The rank order question results in one variable for each item. The value is determined by the selected rank order stored within this variable. The variable name is built up from a combination of question code and item code.

Items with rank 1 and 2 are assigned these variables:
Item 1: q8_1
Item 2: q8_2

Explanation: QuestionCode_ItemCode

This question type is mainly used to have a respondent rank different items. When this respondent has to select three items – in order of importance – from a list of items, which then have to be displayed in, for instance, a text block, you can use the following variables:

Rank 1: q8_rank1
Rank 2: q8_rank2
Rank 3: q8_rank3

Semi-open questions

Example: q1_1_text
Explanation: QuestionCode_ChoiceCode_text

Example: q2_1_text
Explanation: QuestionCode_ChoiceCode_text

Example: q6_1_text
Explanation: QuestionCode_RowCode_text

Example: q6_1_1_text
Explanation: QuestionCode_RowCode_ColumnCode_text

Example: q6_1_1_1_text
Explanation: QuestionCode_RowCode_ColumnGroupNumber_ColumnCode_text

Value of a filtered (not shown) question/choice

The value of a question or a choice that was filtered (i.e. not shown to the respondent) is always 0.

Custom variable

Custom variables can also be used. Just use the prefix ‘custom’.

Example: custom.variable_name

Sample/Panel variable

Sample/Panel variables can also be used. Just use the prefix ‘member’.

Example: member.age

URL variable

URL variables can also be used. There are 20 URL variables, numbered and pre-defined (url.var01, url.var02, etc.). To use them just add the prefix ‘url’.

Example: url.var01

Updated on January 25, 2023