In this article
Use Condition nodes (go to Condition for more information) to create "Skip logic" in your survey. This alters the flow of a survey depending on the answers given to other questions.
A condition item consists of either two or three parts; an IF condition, a THEN clause and an optional ELSE clause. The flow is controlled by a Boolean expression in the IF condition; the expression is designed to evaluate to either TRUE or FALSE. If the expression evaluates to TRUE, the survey-mechanism will execute the items in the THEN node. If the expression evaluates to FALSE, the items in the ELSE node are executed (when the ELSE node exists), otherwise the survey moves on to the next question.
Create the condition logic either by using the condition builder functionality that is included in Survey Designer (go to Building a Condition for more information), or by typing JScript or JavaScript code ‘manually’ into the Expression field in the condition.
Important
If a condition uses scripting then the script will override any categories put in place using the condition builder. A warning message will then be displayed in the condition.
The example - shows a conditional item in a survey, where if the respondent’s answers to two questions both match the selected values then the survey stops. In this case there is no ELSE node
Figure 1 - Example of a conditional item in a survey
When creating a condition, the condition builder uses the question name. If a question name is later changed, then any condition that is based on that question is updated automatically. If a question that has been used in a condition is deleted, then a warning is displayed.
Condition Groups
Grouping condition categories allows you to increase the power of the condition, adding in other clauses and in effect adding parentheses around categories.
In this example an employee satisfaction survey has registered amongst other data, which city (office) the respondent works in, how long they have been with the company, and whether they have a pension plan. A condition then displays an additional information page to those employees who have worked in a specific city for longer than a specified time but who do not yet have a pension plan. Perhaps changes to the company’s pension arrangements now allow employees in other cities the same benefits, so you wish to add that city category to the condition.
Figure 2 - Example of a simple condition to display an information page to relevant employees
- Click Add Condition and add the new city category to the condition.
- Click Create group at the bottom of the page.
- Check the appropriate boxes (in this case the two City categories) and click Save group.
Figure 3 - The additional city is added
Check-boxes are displayed beside each category.
Note: In this case you could simplify the condition's groups by combining the two City categories into the same condition.
The list of conditions is rearranged and the selected conditions are grouped. You must now select whether you want to match all the conditions in the group, or any of them. This allows you to create a very targeted sample group. In this example you would need Any.
Figure 4 - The city categories are grouped and Any is selected
The grouped condition is complete. Now the information page will be displayed to those employees who have worked at either New York or Chicago for six years or more and who do not yet have a pension plan.
You can edit the group, adding or removing conditions and changing the expressions, at any time. To add a category to the group, click the + icon; to edit a category, click on the appropriate blue link within the category. You can re-order the categories within the condition using the up and down buttons to the left of the question names.