/
Using Display Logic in Surveys

Using Display Logic in Surveys

Display logic, sometimes referred to as “branching” or “skip” logic, refers to adding parameters to a survey page or question to determine whether or not they will appear. This is usually based on a participant’s response to a previous question in the survey, but can also be conditioned on other factors, such as global variable value.

For a comprehensive list of display logic, visit: https://surveyjs.io/form-library/documentation/design-survey/conditional-logic

It will be important to note the Question ID for questions on which you wish to condition display logic. The Question ID is the first field visible when editing a question, and must be unique for each question within a survey. W2H automatically populates the Question ID field on any survey with question1, question2, question3, etc. However, you can set these names to be whatever you want/whatever will make analysis easier. Just remember to use the correct Question ID between the {curly brackets} in the display logic of subsequent questions.

 Instructions

To add display logic to a survey question:

  1. Click the blue “Edit” link above the question you want to show/hide

  2. Open the gray drop-down panel labeled “Logic”

  3. Type your expression into the text field. Your expression represents the conditions under which you want the question to display (ergo the “Visible if” text above the field).

 

Some common expressions used in display logic:

  • {question1} = ‘Yes’ This question will display only if the participant answered Yes to question1

  • {question1} >= 5 This question will display only if the participant’s answer to question1 was numeric and greater than/equal to 5

  • {question1} > 5 AND {question1} <=10 This question will display only if the participant’s answer to question1 was numeric and falls between 6 and 11

  • {question1} < 5 OR {question1} > 15 This question will display only if the participant’s answer to question1 was numeric and does not fall between 5 and 15

  • {question1} notempty This question will display only if an answer is entered for question1

  • {{@points}} <= 10 This question will display only if the participant has a value of 10 or less in their {{@points}} global variable

  • {question1} anyof [5, 6, 7] This question will display only if the participant answers a checkbox-type question (i.e., a question that can have multiple answers selected) with any or all of the answer choices coded 5, 6, or 7. This can be used for a single option as well.

  • {questionID.rowName} This is the notation that is used when trying to apply logic from a matrix-based question to another question. For example, {question1.med1}.

 

For more help with creating display logic, feel free to reach out to your implementation lead.

Display Logic for a Page Using Variables

Occasionally, teams will request that certain pages of a survey are only viewable to those in a specific arm. To achieve this, you will need to use display logic with variables in the survey.

  1. Create a list variable for the arms.

    1. Manage StudyVariables+ New Variable → select the ‘List’ option in the dropdown for the variable type → list the arm names

  2. Set the variable value as a set during the enrollment right after randomization (under “Arm Specific Steps”.

    1. The variable being set to the arm that you want can be achieved as a then statement in the logic configuration so that it always occurs.

  3. From there, go back to the survey and navigate to the page where you want the logic to apply.

    1. Manage StudyData Sources → click the pencil icon of the survey you want to change

    2. Click on the gear icon of the page where you want the logic to be applied and click ‘Edit’.

    3. Scroll down to ‘Logic’ and input {{@arm}} = ‘arm name’ in the Visible if box.

 Related articles

Filter by label

There are no items with the selected labels at this time.

Related content

Building: Surveys
Building: Surveys
More like this
Frequently Asked Questions (FAQs)
Frequently Asked Questions (FAQs)
Read with this
Validation and Error Messages in Surveys
Validation and Error Messages in Surveys
More like this
Device Troubleshooting
Device Troubleshooting
Read with this
Survey Link and Survey-Based Value Variable
Survey Link and Survey-Based Value Variable
More like this
Setting up embedded analytics in W2H
Setting up embedded analytics in W2H
Read with this