Feature available for users with Professional or Expert license
This article describes basic concepts related to Value Assignment survey element. Other main related articles are:
Introduction
A Value Assignment is a survey element that allows to fill selected survey variable with a value. It can be used for 3 types of survey variables:
- question variable (e.g. to pre-populate answers)
- sample/panel variable (e.g. to transfer answers into a sample/panel member data)
- custom variable (e.g. to store a calculated score)
Note: Value Assignment element always triggers a page break.
Basic concepts
1. Adding Value Assignment to the survey
Navigate to “Add content” menu and find it in “logic and actions” section:

2. Selecting or creating a variable
It is required to either select already existing survey variable, or create a new custom one. Below you can see an example “ProductName” variable being selected, with “Product A” text value assigned to it:

A custom variable does neither belong to a question nor to a sample/panel. It is only available within the survey for which it was created for. Creating a custom variable is possible in Value Assignment or Script element settings. Click on the “Create variable” button in the settings on the right hand side of the screen. A box opens where variable name and data type can be defined.

3. Assigning text to variable type “string”
When you need to assign text values to a variable, it is possible in the following way. The variable has to be of type “string” to store text.
Note: Quotation marks must be used when assigning text values to string variables.

4. Assigning number (fixed or calculated) to variable type “integer” or “real”
When you need to assign number values to a variable, it is possible in the following way. The variable has to be of type “integer” or “real” to store number values.

5. Using survey variables as part of calculations
Other survey variables can be used in calculations in the following way. Remember that survey variables hold values only when related question was already answered by respondent, or value was assigned in some previous Value Assignment or Script element.

6. Using filter
Value Assignment element can be filtered in the same way as any other survey element. By using filters it is possible to define when each Value Assignment should be executed (shown) or skipped (hidden). This way it can be used e.g. to recode survey answers or create custom segments directly in the survey.

7. Using functions
It is possible to use one of the custom functions to achieve desired result. You can reference the full list of available functions in the article: Script and Value Assignment functions

Value Assignment execution behavior options
Value Assignment can be added anywhere in the survey. However, it is important to define it wisely, because Value Assignment always generates a page break.
Additionally, there are 4 options to control the execution behavior of a Value Assignment:

| Execution Option | Description |
|---|---|
| On survey loading | The value assignment will only be executed under these two circumstances: – if an interview is loaded (also when continuing after intermission) – if the interview language is changed and the interview therefore is newly loaded |
| Only the first time the participant passes this point | The value assignment will be executed only once when the participant reaches this point of the survey. In case a filter skips the value assignment, it will be treated as “not yet executed”. If the participant would come back to this point later and the filter condition would then show the value assignment, it will be executed this time. |
| Every time the participant passes this point | The value assignment will be executed every time the participant reaches this point of the survey, no matter how often the participant uses the back button and goes forward again (by using the next button on the survey page before). |
| Anytime (immediately after every change to an involved variable) | The value assignment will be executed every single time the participant has made any change in the entire survey. This way you can show real-time dynamic content according to the answers of the participant (e.g. automatic sum calculation). Warning: Do not use this setting if real-time calculation result display is not required in your survey. Using this setting extensively might increase loading time of the survey. |
Example Use Cases
The Value Assignment is a powerful tool. To further explain its capabilities, please find several use cases explanation below.

For the name of the element with the first rank in a rank order question, there is no default placeholder available. In order to use it again in next questions, we have to create it with Value Assignment or Script. See example steps below:
- Create a text variable (in this example we’ll call it ‘rank_one’)
- Create one value assignment for each element of your rank order question
- The setting should be ‘Execute everytime the participant passes this point’
- The value of ‘rank_one’ should be set to the label of the corresponding element
- The filter should be set to: Execute only if the corresponding element has rank one

Now you can use the placeholder {{custom.rank_one}} for a question such as ‘Why did you choose {{custom.rank_one}} as rank one?’

There are several randomization features available in Survalyzer as standard survey or question settings. However, sometimes there is a need to randomize elements that don’t have this option by default.
Let’s imagine you want to show one of four questions, but the question should be random. In this case it would be useful to have a random number, that can be used later as a filter.
Example steps:

- Create a value assignment
- Create a number variable (in this example we’ll call it ‘random_number’)
- The execution setting should be ‘Execute only the first time the participant passes this point’
- The value of ‘random_number’ should be set to randomInt(1,5). This function will create a random number between 1 and 4 (the maximum value is excluded).

Now you can use this ‘random_number’ variable as the filter variable for the four questions. You should set a filter like: ‘Show this element if ‘random_number’ is equal to 1′.

Let’s imagine you want to use Survalyzer as a tool to conduct a test, for example, for a school class. On the final page you want to show the number of points scored, with a corresponding grade. For this to work, we need some preparation. For each question we will need to create an own number variable. We will also need to create two value assignments per question (only if the participant is allowed to go backwards):

- one value assignment to set the variable to 0 (which happens when the participant passes this element)
- a filtered value assignment which sets the value to the number of points the participant gets for this question; filtered to only assign this value if the question is answered correctly. The setting should be ‘everytime the participant passes this element’.
At the end of the survey we’ll create an additional variable, let’s call it ‘sum_points’, where we will store the sum of all question variables. For example: pq1+pq2+pq3…etc.

- a filtered value assignment which sets the value to the sum of all points; the setting should be ‘every time the participant passes this point’.
Now we have a sum of all points attained, stored in a variable. For each grade we now need to create a text block. Here we’ll use our ‘sum_points’ variable as a filter variable and placeholder, to show the number of points attained. Now we have a working test in place.
Sometimes you may need to set a complex filter several times at different places in your survey. There is a way to make this easier.
To do this you’ll need to create two value assignments (only if the participant is allowed to go backwards) directly after you gathered all necessary information for your complex filter:

- one value assignment to set the variable (let’s call it ‘complex_filter’) to 0 (which happens whenever the participant passes this element)
- a filtered value assignment which sets the value to 1; the setting should be ‘everytime the participant passes this element’.
- The Filter to set is your complex filter

Now you can simply use the filter ‘show this element if ‘complex_filter’ is equal to 1′. This is much easier to set than repeatedly creating a complex filter. Additionally, if you need to update the filter, you only have to change it in one place.
Value assignments in calculation filters
In filter conditions of the ‘calculation’ type, you can compare variables and/or calculations with each other. The corresponding fields use the same functions as Value Assignment, so in principle all functions presented here can equally be used in calculation filters.
This type of filter can be used for any survey element, not just Value Assignment.
Checking a constant sum is an example of a calculation filter with numerical variable values. Initial situation: The participant is to distribute exactly 100 points or 100% to the listed options. One now adds a validation that is to display a validation text with the help of a filter, if the sum does not add up to 100. The filter of the ‘calculation’ type uses the basic functions of the basic arithmetic operations. On the left side, the variables of the individual options are added together. On the right side, the value 100 is entered. Both are matched:

A calculation filter for text variables which is to check whether two variables share exactly the same content must use the equals() function, which was displayed at the text functions. The input on the right side of the calculation filter cannot distinguish whether it is text or a variable name. Basically, text will be assumed. Thus, the text comparison is to be set up using the mentioned function and the values “true” or “false”:

The calculation filter is also used when comparing two dates. Both dates are converted into numerical timestamps – as described with the date functions – which then enable a comparison. The date2number() function being used can be specified on the left as well as on the right in the filter condition.
