Conditions: show a question only when it applies | LimeSurvey

Conditions: show a question only when it applies

About conditions

A condition decides whether participants see a question. The question appears only when its condition is true, for example a follow-up question that only laptop users get. Otherwise it is skipped. You build conditions with the Condition designer in Question settings, and LimeSurvey writes them as an expression that you can also edit directly. Question groups have a condition of their own.

Add a condition to a question

  1. Select the question that should appear only sometimes.

  2. In Question settings, under Condition designer, click + New logic. The designer opens in the panel.

  3. Under Display only if, leave Question selected to use an earlier answer. Participant data uses a field of the participant list instead.

  4. Choose the earlier question in Previous questions (1). Only questions that come before this one are listed.

  5. Choose the comparison (2): equals, Not equal to, Less than, Less than or equal to, Greater than, Greater than or equal to or Regular expression.

  6. Under Reference value (3), choose what to compare with, then the value. Select answer option(s) lists the answer options of the earlier question: pick one or more. The other choices are Free value (constant), Compare to answer of other question and Participant data, and RegExp for the comparison Regular expression.

  7. Click + Add condition (4) for another condition, or Apply (5).

The Condition designer with five areas numbered 1 to 5, the earlier question, the comparison, the reference value, Add condition and Apply

LimeSurvey confirms with Condition applied successfully. The question gets a C badge in the editorial area (1), and the condition is listed as Scenario 1 with its expression (2), here ((Q001.NAOK == "A002")): show the question when the answer to Q001 has the code A002.

A question with the C badge and its condition listed as Scenario 1 with its expression, numbered 1 and 2

Combine conditions

  • Several answer options in one condition: the question shows when any of them was chosen.
  • Several conditions in one scenario: build them with + Add condition. A question with conditions on different earlier questions shows only when all of them are true.
  • Several scenarios: the question shows when any scenario is true. To add one, click + New logic again and change Default scenario from 1 to 2. The expression then joins the scenarios with or.

Edit or remove a condition

  • Edit the expression in the field under the scenarios, or build a new condition with + New logic.
  • To remove a scenario, click the x next to it and confirm with Delete.

Show a question group only sometimes

Click the group in the Structure panel. In Group settings, type an expression into Condition, for example Q001 == "A002". 1 means always. When the expression is false, the whole group is skipped.

Tip: Conditions compare codes, not texts: A002 is the code of the answer Laptop. Turn on ... > View > Question codes to see the codes, and test the survey with the eye icon in the top bar before you activate it.

Next steps

FAQ

Why is a question missing from Previous questions?

A condition can only use questions that come earlier in the survey. Move the question you want to use above the one that gets the condition.

The question with a condition still shows in the preview. Why?

Check the answer code in the condition against the answer you gave in the preview. With Question codes on, the code of each answer option is shown next to it.

    • Related Articles

    • Question settings

      About question settings Question settings is the panel on the right that opens when you select a question. It has two views. Simple shows the settings most questions need. Advanced shows every setting of the question type, sorted into sections. Which ...
    • Question and answer codes

      About question and answer codes Every question has a question code, such as Q001, and every answer option has an answer code, such as A001. Participants never see them. You use them: they identify questions and answers in exports, conditions, ...
    • Validation: make sure the answers you get are usable

      About validation Validation checks answers before participants can move on. It ranges from requiring an answer to rules you write yourself as an equation. Everything is set per question in Question settings. Require an answer Select the question and ...
    • ExpressionScript: quick start

      About ExpressionScript ExpressionScript is the logic of LimeSurvey. An expression is a short formula, such as Q001 == "A002" or sum(Q024_SQ001, Q024_SQ002). LimeSurvey uses expressions to show a question only when it applies, to put earlier answers ...
    • Piping: use answers from previous questions

      About piping Piping puts an earlier answer into a later text, for example "What do you like most about your Laptop?" after a participant chose Laptop. You insert a placeholder with the question code in curly brackets, and LimeSurvey replaces it with ...