You can use display logic to create surveys that are customized to each respondent. When a specific question or answer choice pertains only to certain respondents, you can hide it conditionally, based on previous answers or metadata. Through display logic, you can create surveys that dynamically adapt to your respondents’ answers and custom fields.
Display logic can be configured in one of two ways: using dropdown selections, or using CSL.
Dropdown conditions
When using dropdown selections to set up your display logic conditions for your question or answer choices, you can choose to conditionally show or hide your question or answer choice using the initial show/hide dropdown. From there, you can choose whether you want to hide it based on respondent metadata, contact metadata, or the answer to a previous question.
In this example, you can see that the question will be conditionally hidden for all respondents who have identified as female. In this case, when a female respondent reaches this question, it will be skipped over and they will be sent directly to the next available question in the survey.
The list of dropdown operators available to select will vary based on which type of question (or metadata) you are basing your condition on. The full list of operators is as follows:
- Is — The display logic conditions (show/hide if) are only met when the respondent’s selection exactly matches the answer options(s) that are chosen in the display logic condition setup.
- Is not — The display logic conditions (show/hide if) are only met when the respondent’s selection does not exactly match the answer options(s) that are chosen in the display logic condition setup.
- Is greater than — The display logic conditions (show/hide if) are only met when the respondent’s selection is a value larger than the selected number in the display logic condition setup. (If the values are not numerical, the conditions are met when the respondent’s selection is presented after the answer option in the condition setup.)
- Is greater than or equal to — The display logic conditions (show/hide if) are only met when the respondent’s selection is a value larger than or equal to the selected number in the display logic condition setup. (If the values are not numerical, the conditions are met when the respondent’s selection either matches the answer option in the condition setup or is presented after the answer option in the condition setup.)
- Is less than — The display logic conditions (show/hide if) are only met when the respondent’s selection is a value smaller than the selected number in the display logic condition setup. (If the values are not numerical, the conditions are met when the respondent’s selection is presented before the answer option in the condition setup.)
- Is less than or equal to — The display logic conditions (show/hide if) are only met when the respondent’s selection is a value smaller than or equal to the selected number in the display logic condition setup. (If the values are not numerical, the conditions are met when the respondent’s selection is selected in the condition setup or is presented before the answer option in the condition setup.)
- Is one of — The display logic conditions (show/hide if) are only met when the respondent selects at least one of the answer options that you have specified in your display logic condition setup.
- Is not one of — The display logic conditions (show/hide if) are only met when the respondent does not select any of the answer options that you have specified in your display logic condition setup.
- Is answered — The display logic conditions (show/hide if) are only met when the respondent answers the question (or when metadata is present for the field) that you have specified in your display logic condition setup.
- Is not answered — The display logic conditions (show/hide if) are only met when the respondent does not answer the question (or when metadata is not present for the field) that you have specified in your display logic condition setup.
- Contains all of — The display logic conditions (show/hide if) are only met when the respondent selects every single one of the answer options that you have specified in your display logic condition setup. The respondent could select additional options, but the options you specified in the condition must be present in order for the condition to be met.
- Does not contain all of — The display logic conditions (show/hide if) are only met when the respondent does not select every single one of the answer options that you have specified in your display logic condition setup. If the respondent selects some of the specified options, the condition will not be met.
Configuring question display logic
- Open the survey containing the questions to which you want to add question display logic.
- Select Questions from the survey options menu.
- Select the dropdown next to the question and click Edit.
- Select the Display logic tab. Depending on the question type, you can set the logic for the entire question, sub-questions, and answer choices.
- For the item you would like to conditionally show or hide, select Hide if (or Show if) from the dropdown.
- Click Add condition. Then select the Select Criteria dropdown.
If you select Respondent metadata, Contact metadata, or Questions in the survey as your criteria, proceed with using the subsequent dropdowns to set up your conditional display logic to determine if the item should be hidden.
If you select CSL as your criteria, in the textbox that appears, enter or paste the CSL condition that you would like to use to determine if the item should be hidden. If the condition is true, then the item will be appropriately hidden (or shown) to the respondent according to your Hide if / Show if condition to the respondent. If the condition is false or invalid, the item will be shown if you selected Hide if (or hidden if you selected Show if).
CSL conditions
The display logic can also be set using CSL by selecting the CSL option from the criteria selection dropdown and entering your desired CSL conditions. The display logic is set using CSL. A CSL condition is a statement that is either true or false.
Here is a simple example that will return true:
{{eq 1 1}}
Translation: The ‘eq’ stands for ‘equals’. In CSL, the operator is always placed first. The other two items are what is being compared so it says ‘1 is equal to 1’. This is true.
Here is an example that will return false:
{{eq 1 2}}
It says ‘1 is equal to 2’. This is false.
CSL conditions can be used in logical operators like ‘if’ statements and they can be used in question display logic.
For example, in question one, respondents are asked how many children they have. Later you have a checkboxes question asking about favorite things to do on the weekend. One of the answer choices is ‘Taking kids to the park‘. You would not want to show that answer choice for respondents that don’t have children. So you would set the display logic for that answer choice to be ‘Hide if‘ and use the following CSL condition:
{{eq respondent.questions.children_count 0}}
Translation: The ‘eq’ stands for ‘equals’. You could use other operators here too, like ‘gt’ (greater than). The variable in the middle refers to the children count question using its data label. So it says: Is the answer the respondent gave to the children count question equal to 0?
Examples
If you select Hide if in the dropdowns on the Display logic tab, you can use these example conditions to get started. See our CSL page for more operators. See our CSL survey variables page for a list of variables that you can use.
Condition | Description |
---|---|
| Respondent selected answer choice 1 in the question with the data label ‘myLabel’. |
| Respondent selected answer choice 1 in the first sub-question. |
| Respondent did NOT select answer choice 1. The NOT reverses the result. So if something is true, adding a not in front makes it false. |
| 20 or more respondents selected answer choice 3. |
| Combine multiple conditions using and (All terms must be true). |
| Combine multiple conditions using or (At least one of the terms must be true). |
| When using a ‘not’, each term is evaluated to true or false and then finally reversed so that rule becomes false and false becomes true. |
Looking at the last ‘not’ example above, let’s assume for example, the respondent answers choice 7. Simplified, the code can then be seen as:
{{not (or false true)}}
The or is true since the respondent answered one of the two answer choices, so you get:
{{not (true)}}
‘Not’ makes the true become false:
{{false}}
Leave a Reply