Conditions and Logic

During a survey, questions are displayed in the sequence in which they are arranged in the survey editor. There might be a need to hide certain survey items, such as questions, answer options, or matrix questions (rows), based on logical conditions. Also, under certain conditions, there may be a need to terminate the survey (screener) or display an error to the user by setting an error text. For these purposes, there is a condition builder.

All the described actions are performed on the "Logic" page. To navigate to this page, click "Editor" in the survey list and then the "Logic" button in the top right corner. Each of the elements is described in more detail in the section below. The condition builder is described at the end of this section.


Hiding Questions

To hide a question based on a condition, you need to move the question into a group and set a condition for the group. This is described in more detail in the "Hiding Groups" section.


Hiding Groups

To hide items within a group, go to the "Logic" page and, while on the "Conditions" tab, select the required group. Then click on the three dots and in the condition builder create a condition (described in more detail in the "Condition Builder" section). The group will be displayed if the condition is met. Thus, the group will be hidden if the condition is not met. If there is no condition, the group will also be displayed.

If a condition is set for the group, a blue circle will be displayed next to it.

To delete a condition, click on the three dots and select "Delete condition".


Hiding Answer Options

To hide answer options of a selectable question, answer options (columns) or questions (rows) of a matrix (hereinafter referred to as an "element"), navigate to the "Logic" page and, while on the "Conditions" tab, select the necessary element. Then click on the three dots and in the condition builder create a condition (described in more detail in the "Condition Builder" section). The element will be displayed if the condition is met. Thus, the element will be hidden if the condition is not met. If there is no condition, the element will also be displayed.

If a condition is set for the element, a blue circle will be displayed next to it.

To edit a condition, click on the three dots and select "Edit condition". To delete a condition, click on the three dots and select "Delete condition".


Screener

To interrupt the survey (screener) based on a condition, go to the "Logic" page and, while on the "Screener" tab, click "Add". Enter a description for the screener (visible only to administrators) and create a condition in the condition builder. If the condition is met, the survey will be interrupted and the survey status will be set to "Screener".

Any number of screeners can be created.

To edit a screener, click "Edit".

To delete a screener, click "Delete".


Question Validation by Condition

If it's necessary to display an error to the user on a specific question when a certain condition is met, go to the "Validation" tab on the "Logic" page. Select the required question and click "Add". Enter the error text and create a condition in the condition builder. If this condition is met, the user will see the error and will not be able to continue with the survey. The error text can be formatted (bold, italic, underline), and a Flow expression can also be inserted (described in more detail in the Flow section).

For example: for question Q1, if the sum of the values of fields with ID 1 and ID 2 does not equal 100 and you need to display the error "Sum does not equal 100". For this, for question Q1, enter the error text "Sum does not equal 100", and in the builder in Flow mode, enter the Flow expression (${Q1[1]|value} + ${Q1[2]|value}) != 100

Second example: the price entered by the user for the product (Brand 3) in question Q7.1 (answer option 1) cannot be less than $5. The Flow expression in this case would be: ${Q7.1[1]} < 5


Condition Builder

The condition builder appears when there is a need to create a condition. The condition builder can operate in builder mode or in Flow expression mode. To switch between modes, use the toggle


Builder Mode

To create a condition in builder mode, select a question. The condition can refer to questions that are positioned before the element for which the condition is being set. In the case of "Question validation by condition", the condition can refer to the question itself for which the error is being set. Thus, only those questions that the condition can refer to will be available in the list.

Note: The builder mode allows for the creation of simple conditions. If you need to build a complex condition where "AND" and "OR" operators alternate or mathematical formulas are used, then you should use Flow mode.

After selecting the question, a list of answer options (if the question is selectable) or a list of matrix questions (rows) and answer options (columns) (if it's a matrix) will appear. Select the required answer option if it's a selectable question. If it's a matrix question, select the matrix question (row) and the answer option (column) of the matrix (the condition refers to the matrix cell).

Then, depending on the type of answer option or matrix cell type, operators will appear.

List of operators for types:

  • Closed (default)
    • Selected (answer option is marked)
    • Not selected (answer option is not marked)
  • Text
    • Selected
    • Not selected
    • "=" - equal to the given text
    • "!=" - not equal to the given text
  • Numeric
    • Selected
    • Not selected
    • "=" - equal
    • "!=" - not equal
    • ">=" - greater than or equal to the given number
    • "<=" - less than or equal to the given number
    • ">" - greater than the given number
    • "<" - less than the given number
  • Date
    • Selected
    • Not selected
    • "=" - equal
    • "!=" - not equal
    • ">=" - greater than or equal to the given date
    • "<=" - less than or equal to the given date
    • ">" - greater than the given date
    • "<" - less than the given date
  • Time
    • Selected
    • Not selected
    • "=" - equal to the given time
    • "!=" - not equal to the given time
    • ">=" - greater than or equal to the given time
    • "<=" - less than or equal to the given time
    • ">" - greater than the given time
    • "<" - less than the given time
  • Rating
    • Selected
    • Not selected
    • "=" - equal
    • "!=" - not equal
    • ">=" - the rating value is greater than or equal to the given number
    • "<=" - the rating value is less than or equal to the given number
    • ">" - the rating value is greater than the given number
    • "<" - the rating value is less than the given number
  • List
    • Selected
    • Not selected
    • "=" - equal to the ordinal number of the item in the list
    • "!=" - not equal
    • ">=" - the ordinal number is greater than or equal to the specified number
    • "<=" - the ordinal number is less than or equal to the specified number
    • ">" - the ordinal number is greater than the specified number
    • "<" - the ordinal number is less than the specified number

After selecting the operator, enter the value (no value entry is required for the "Selected" or "Not selected" operators). A calendar will appear for date entry. A time scale will appear for time entry.

After this, you can add an additional condition through the "AND" or "OR" operator. The number of conditions can be any.

After setting the necessary conditions, click "Save".

It is recommended to use only "AND" or "OR" operator in one condition.


Flow Expression Mode

Flow mode allows setting conditions in Flow expression mode (detailed in the Flow section).

The type resulting from the Flow expression evaluation must be logical (boolean). If the result is of another type, an error "Incorrect evaluation type" will be displayed upon saving.

For example, to create a condition where it is checked:

  • If answer option with ID 1 in question Q1 is selected, enter: ${Q1[1]|checked}. For a matrix with row ID 2 and answer option ID 3, the expression would be: ${Q1[2][3]|checked}.
  • If the numeric value entered by the user in question Q3 for answer option ID 2 equals 2: ${Q3[2]|value} == 2.
  • If the sum of answer options with IDs 1, 2, and 3 in question Q4 equals 100: (${Q4[1]|value} + ${Q4[2]|value} + ${Q4[3]|value}) == 100
  • If the date entered in question Q5 for answer option ID 1 is greater than today's date: ${Q5[1]|value} > currdate()
  • If either answer option with ID 1 in question Q6 is selected or answer option with ID 1 in question Q7 is selected: ${Q6[1]|checked} || ${Q7[1]|checked}

After entering the Flow expression, click save. When saving, the expression's evaluation types and syntax are checked. If there is an error, it will be displayed on the screen.