ichivite-esristaff

The art of hiding

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

This blog post is all about using the relevant column in your XLS file to hide orSmaller.gif 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':

 

Relevant01.PNG

 

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.

 

Capture.PNG

 

To learn more about select_multiple questions, have a look Understanding Multiple-Choice Questions in Survey123 for ArcGIS 

 

Relevant expressions can be applied to many different types of questions: select_one, integer, text, image, barcode, repeat etc. You can also apply them to notes as well as to Groups and RepeatsGroups are of particular importance because a relevant statement applied to a Group will have effect over all questions within that Group.  If you have three or four questions to which you want to apply exactly the same relevant expression, you may want to consider creating a Group and apply the expression only to the Group. This will make your Survey load faster because you will be reducing the number of times the expression needs to be evaluated.

 

Another aspect to keep in mind is the effect relevant statements have on submit. If a question is not relevant (it is hidden), then data in that question will not be submitted to ArcGIS.

 


Outcomes