Conditions: Display a Different Question depending on ‘Yes’ or ‘No’”.

Introduction to LimeSurvey Survey design Settings
2025-12-02 11:33:20
Admin

Objective

  • Create a logical branching in LimeSurvey.
  • Display different questions based on the answer to an initial question.
  • Use the "Condition" feature to manage conditional paths.

Why use conditions?

  • To personalize the path for each respondent based on their answers.
  • To avoid asking irrelevant questions to certain participants.
  • To create dynamic questionnaires adapted to the context.

1. Creating the base question (Q1)

This question determines the logical branching. It is generally a Yes/No question.

  1. Create a new question in your question group.
  2. Select the question type (for example, "Dropdown list" or "Radio buttons").
  3. In the "Code" field, enter a simple code to identify this question (example: INTERVENTION).
  4. Add the answers with their codes:
    • Answer: Yes > Answer code: Y
    • Answer: No > Answer code: N
  5. Save the question.

Note: The question code (INTERVENTION) and the answer codes (Y, N) are essential. You will use them to write the conditions.



2. Creating the question for the "Yes" answer (Q2_Yes)

This question only displays if the user answered "Yes" to Q1.

  1. Create a new question right after Q1.
  2. Configure the content of this question (text, type, answers).
  3. Click on the "Settings" tab in the question options.
  4. Locate the "Condition" field in the general settings.
  5. Enter the following equation in the "Condition" field:

INTERVENTION == 'Y'

Explanation: This equation means "Display this question only if the answer to the INTERVENTION question equals the answer code Y (Yes)".

  1. Save the Q2_Yes question.

3. Creating the question for the "No" answer (Q2_No)

This question only displays if the user answered "No" to Q1.

  1. Create a new question right after Q2_Yes.
  2. Configure the content of this question (text, type, answers).
  3. Click on the "Settings" tab in the question options.
  4. Locate the "Condition" field in the general settings.
  5. Enter the following equation in the "Condition" field:

INTERVENTION == 'N'

Explanation: This equation means "Display this question only if the answer to the INTERVENTION question equals the answer code N (No)".

  1. Save the Q2_No question.

4. Testing the logical branching

Verify that your condition works correctly.

  1. Click on the "Preview survey" or "Preview question group" icon.
  2. Answer "Yes" to question Q1. You should see only the Q2_Yes question appear.
  3. Restart the test and answer "No" to Q1. You should see only the Q2_No question appear.

Tip: If the questions appear as expected, your logical branching works perfectly.

5. Troubleshooting

The condition does not work or all questions are displayed

Solution: Verify that you are using the answer codes (Y, N) and not the answer text (Yes, No). Also check that you used the double equal sign ==.

Conditional questions never display

Solution: Make sure that single quotes ' properly surround the answer code. The correct syntax is: INTERVENTION == 'Y' and not INTERVENTION == Y.

Syntax error in the condition

Solution: Check the case (uppercase/lowercase) of the question code and answer codes. LimeSurvey is case-sensitive: INTERVENTION is different from intervention.

6. Best practices

  • Use short and explicit codes for your questions (for example, Q_BASE, INTERVENTION).
  • Document your answer codes in an external file to facilitate maintenance.
  • Systematically test each branch after its creation.
  • Avoid ambiguous answer codes like 1, 2 which can be confused with numerical values.

Need help?

For any difficulty, contact the LimeSurvey team via: Cellule.Web@ulb.be

On the same topic