# The art of hiding

Blog Post created by ichivite-esristaff on May 28, 2016

This blog post is all about using the relevant column in your XLS file to hide or show questions in your survey. The relevant column is present in the survey worksheet and can optionally hold an expression, which will make the corresponding question be hidden if it evaluates to false, or show the question if it evaluates to true.

Hiding and showing questions can help you simplify your survey. Relevant expressions will also let you show notes when appropriate to facilitate data entry.

Lets go first through some examples:

Say you only want to ask a question if the response to a previous question is 'yes':

typenamelabelrelevant
select_one yes_noowner_presentIs the house owner present?
textowner_nameName:selected(\${owner_name},'yes')

Other relevant expressions may include:

• \${PreviousQuestion} < 18
• int(\${QuestionA})+ int(\${QuestionB}) > 100
• today() - \${LastInspectionDate} > 1000*60*60*24*15 (the last inspection happened more than 15 days ago)

When using mathematical operators, one needs to be careful with empty responses. If a question has not been answered, it evaluates to 0. This would make for example \${PreviousQuestion} < 18 always return true, if \${PreviousQuestion} has not been answered.  To resolve this issue, you can add your expression to an if block as follows:

• if (condition, a, b)  If the condition is met, returns a, otherwise returns b.
• if(string-length(\${PreviousQuestion}) = 0, false, \${PreviousQuestion} < 18)
• if(string-length(\${LastInspectionDate})=0, false, today() - \${LastInspectionDate} > 1000*60*60*24*15)

The safest way to check if a question has  been answered is using string-length(\${QuestionName}).  If string-length returns 0, then you known the answer is empty. This function works well with question types of all sorts: with numbers, text, images, dates etc

In some cases, you may want to use regular expressions (regex) For example, the following expression can be used with a note type of question. If the expression evaluates to  true, the note is shown, otherwise it is hidden.

• regex(\${Q2}, '[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}') (user typed a valid e-mail address in Q2)

A special case when using relevant statements are select_multiple questions. For them, the count-selected and selected statements are very handy.