Index of help pages

How to make a conditional question in LimeSurvey

"Magical" {}-expression

Make a question and put name in the Code-field. You can left the type as Long free text, and let the question itself be empty.

Save and add a new question. To the question text put Hello {name}.

Test with Preview question group -button. Hooray! You have just made your first question having a reference to some earlier question.

Use expression as condition

Now modify the latter question. To the Condition put name != 'Tom'. Save and again test with Preview question group -button.

Now the second question disappears when you wrote "Tom" to the first question.

Basically, that's it. Just refer to an earlier question in a Condition-field. And if you are not sure about what to write, use {}-magic to see the value before using it as a condition.

More realistic examples

More realistically you may do for example a short text question with code age and have a condition like age >= 65. You can also have more complicated conditions, like age >= 18 and age <= 64.

You can also compute with values, like weight > length-100. First test with {}-stucture in a question text.

Referring to subquestions

For a Radio button -type question the value is the Code of the Answer option selected. If you have question "gender" with an option "Man" with code "AO02", then the condition for a question about moustaches can be gender == 'AO02'.

In a question of type checkboxes the subquestion code is question_subquestion. For example it can be pets_cat assuming that you use "cat", "dog" etc. as subquestion codes and not "AO01", "AO02" etc. The value is nothing if not checked and Y if checked. Hence the conditiong could be pets_cat == 'Y'.

Condition for question group, question and subquestion

LimeSurvey has no logic of type "If answer to question 1 is X then jump to question 5.". However, you can make a question group from questions 2, 3 and 4, and add a condition to the group. If that is not possible, then you must manually copy the condition to several questions.

Subquestions — i.e. checkboxes — can also have a condition. For example "What drinks you like?" can have a subquestion "Coffee" with condition religion != 'mormon'.

On the other hand there is not conditions for answer options in a radio button -type question. Sometimes you may use array filtering -feature to overcome this limitation.

You can find examples listed here in this example file.