Expressions
PrintYou can use "Expressions" to control when pages, questions, and choices are displayed.
Expressions can use a variety of functions and variables for conditional logic.
Simple Expressions
You can create simple expressions using a Question's name or title inside of an expression.
The syntax for using a Question's name is:
The syntax for using a Question's title is:
For example, imagine if you are doing that asks respondents about the number of kids they have and you want to collect the age of each child. You can use a Visible If expression to conditionally display certain questions based on the number of kids.
Logical Operators
Expressions can contain the following logical operators:
- > means greater than
- < means less than
- >= means greater than or equal to
- <= means less than or equal to
- = means equal to
- != means not equal to
- notempty means the value is not null
Questions vs Choices
Every ItemValue object has its own Visible If property. You may override the top level choicesVisibleIf property and define visibleIf expression for an individual choice item.
Building Expressions
Use a Choice's Value
You can build expressions around the value of a prior Choice. For example, you created a Question named pricelimit where the respondent could enter two values, one named leastamount and another named mostamount.
Use the 'contains' Function
The "contains" function can be used to check if Choices from a question contain a specific value.
To get the current item value, you can use {item} variable in your expression. The following expression below means: the item is shown if the same value is checked in the {car} question and it is not selected in the {bestcar} question.
rowsWithValue()
In Matrix questions, you can use the rowsWithValue() function to build logic based on the number of responses in a particular row. This function has the following syntax:
rowsWithValue({ROW_NAME}, {COLUMN_VALUE}') >= TOTAL_RESULTS
- The row name and column name can be entered either using the choice ID in curly brackets or using the actual name in single quotes
- You can use any Logical Operator (see Logical Operators section in this document
The following example will look check if there are at least three rows in the matrix where the Quality was set to Disagree: