# Relevant expressions

A question, or a set of questions, can be hidden and revealed based on previous answers using relevant expressions. These expressions are entered into the relevant column, and the answers to previous questions are always referred to as \${field_name}. You can apply a relevant expression to a single question, or you can group questions together and set the relevant expression for the entire group.

## Simple relevant expressions

The simplest way to use the relevant column is to conceal a question unless a particular answer was given previously. For example, this expression will reveal a question if the answer to the previous question is true:

\${previous_question} = 'true'

This example will hide questions if the answer to the previous question was greater than or equal to 100:

\${previous_question} < 100

select_multiple questions hold their values differently than other question types, with each checked answer entered in the order it was selected, separated by commas. For example, selecting answers A and B, in that order, will present the response as A,B. To use a select_multiple question as part of a relevant expression, you'll need to use the selected command. This example would display a question if the answer to the previous question was A:

selected(\${previous_question}, 'A')

The count-selected command counts the amount of options that have been selected in a select_multiple question, providing a number to use as an operator. This example would show a question only if the previous question had more than two choices selected:

count-selected(\${previous_question})>2

## Mathematical relevant expressions

This example combines multiple operators and questions:

\${previous_question} + \${other_previous_question} <= 100

When using mathematical operators, be aware that sometimes you may need to cast values into numbers. In the previous example, it was assumed that previous_question and other_previous_question were integers or decimals, but what if the question types were strings? Then you cast them as follows:

int(\${previous_question}) + int(\${other_previous_question}) <= 100

You can also perform mathematical expressions on date questions, which are saved as Epoch time, the amount of milliseconds passed since January 1, 1970. This expression reveals a question only if the answer to the previous question is more than two weeks before today:

if( \${previous_question}='',false,today() - \${previous_question} > 1000*60*60*24*15)

## Regular expressions

Regular expressions can be used in relevant columns to restrict access to a question unless the string provided by another question is in a given format. This example will only display a question if another question has been answered with only letters:

regex(\${question},'[A-Za-z]')