Help Center

Question Display Logic

No comments

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.

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?

Steps

  1. Click on the dropdown next to the question.
  2. Click on Edit.
  3. Click on the Display Logic tab.
    Depending on the question type, you can set the logic for the entire question, sub-questions and answer choices.
  4. Look for the item you would like to conditionally hide and select Hide if.
  5. 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 not be shown to the respondent. If the condition is false or invalid, the item will be shown.
survey question answer choice display logic
Note! The source question must be on a previous page. The conditions are checked only once, when the page is loaded.

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.

ConditionDescription
{{eq respondent.questions.1 'test'}}
Respondent answered ‘test’ to question 1.
{{not respondent.questions.1.answerChoices.2}}
Respondent did NOT select answer choice 2 in question 1 (blanks are false).
{{ge survey.questions.1.answerChoices.3.results.respondentCount 20}}
20 or more respondents selected answer choice 3 in question 1.
{{and (eq respondent.questions.1 'test')
     (eq respondent.customfields.1 'test')}}
Combine multiple conditions using and (or is also possible).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.