Select to view content in your preferred language

Relevant Question Dependent on Multiple Fields

6126
9
10-28-2016 10:04 AM
TiffanyRufo
Frequent Contributor

I am working on transferring a paper inspection form into a Survey123 form. My question is this:

   

Can you write a relevance expression that will be based on multiple fields value?

CONTEXT:

   I have three fields in a group that have other questions dependent on an answer supplied from a selection. The final question is the comments box, which I would like to set up so that the Comments question only appears if one or more of the 'in compliance?' questions have been answered as no.

Currently the comments box is visible even when there have been no violations reported.

I am just not sure if I don't know how to phrase it properly, or if it is not a supported function at the time.

Thanks for any and all help!Survey123 for ArcGIS#survey123 connect#syntax#xls forms#xlsform#relevant expression

9 Replies
RickeyFight
MVP Regular Contributor

I believe this is possible: 

"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 group questions together and set the relevant expression for the entire group."

Relevant expressions—Survey123 for ArcGIS | ArcGIS 

TiffanyRufo
Frequent Contributor

Thank you! I am glad to hear that it may be possible. I have tried writing it out in several different ways, but when I update the form it throws an error saying that I have broken the Parser or that it is invalid. My guess is that I just don't know how to properly write the syntax. I have tried:

${Compliant_San} = 'no', ${Compliant_RG} = 'no', ${Compliant_Scrn} = 'no'  Result= Xform invalid

(${Compliant_San} = 'no', ${Compliant_RG} = 'no', ${Compliant_Scrn} = 'no') Result= Xform invalid

${Compliant_San} = 'no' ${Compliant_RG} = 'no' ${Compliant_Scrn} = 'no'       Result= >> Somethng broke the parser. see hint. Invalid.

I have not been able to find any resources on xlsform syntax (most likely b/c I don't know where to look) I am a total newbie outside of the youtube tutorials and the help page.

TiffanyRufo
Frequent Contributor

Also tried:

'concat ' ${Compliant_San} = 'no', ${Compliant_RG} = 'no', ${Compliant_Scrn} = 'no' '

'concat (${Compliant_San} = 'no', ${Compliant_RG} = 'no', ${Compliant_Scrn} = 'no')'

concat (${Compliant_San} = 'no', ${Compliant_RG} = 'no', ${Compliant_Scrn} = 'no')

Same result:

Still trying

RickeyFight
MVP Regular Contributor
0 Kudos
deleted-user-Xptbi2bLfMNa
Deactivated User

THE ANSWER .....for including multiple FIELDS or RESPONSES to a question (like 3 or more choices that would trigger RELEVANT) 

THE ANSWER is in the OPERATOR .....very simple (I was using OR .....and the correct operator is.....   or) 

example from workflow (in this case we do not want DMS_DIRECTION to appear unless a form of DMS is chosen) 

selected(${DEVICE_TYPE}, 'DMS') or selected(${DEVICE_TYPE}, 'DMS_W_RADAR') or selected(${DEVICE_TYPE}, 'DMS_w_TRUCKENTRY')

works beautifully

0 Kudos
MichaelKelly
Frequent Contributor

You can link relevant statments together using either and or or.

and indicates that the relevant statments must all be true for the relevant question to be shown:

${Compliant_San} = 'no' and ${Compliant_RG} = 'no' and ${Compliant_Scrn} = 'no'

or indicates that one of the relevant statments must be true for the relevant question to be shown:

${Compliant_San} = 'no' or ${Compliant_RG} = 'no' or ${Compliant_Scrn} = 'no'

You can also use brackets to use a combination of these - this displays if Compliant_Scrn and one other question equals no:

(${Compliant_San} = 'no' or ${Compliant_RG} = 'no') and ${Compliant_Scrn} = 'no'

See the follow Excel form (also attached) for a demonstration:

typenamelabelhintappearancerelevant
select_one ChoicesYesNoQuestion1Question 1horizontal
select_one ChoicesYesNoQuestion2Question 2horizontal
select_one ChoicesYesNoQuestion3Question 3horizontal
textRelevantQuestionARelevant Question ADisplays if all 3 questions equal No${Question1} = 'No' and ${Question2} = 'No' and ${Question3} = 'No'
textRelevantQuestionBRelevant Question BDisplays if any of the 3 questions equal No${Question1} = 'No' or ${Question2} = 'No' or ${Question3} = 'No'
textRelevantQuestionCRelevant Question CDisplays if Question 3 and one of the other answers equal No(${Question1} = 'No' or ${Question2} = 'No') and ${Question3} = 'No'

Note, if you are using select_multiple questions, you also have to use the selected() function.

AndrewHargreaves2
Deactivated User

Michael Kelly‌ can you help me out with a similar issue?  I have 10 questions, 5 asking ab out MATERIAL and 5 asking about QUANTITY. I wish to hide each QUANTITY until the MATERIAL question has been chosen. So for QUANTITY2 the below relevant statement works great:

${MATERIALS2}!='PLEASE_ANSWER' and ${MATERIALS2}!=${MATERIALS1}

However, for QUANTITY3 the below statement fails to work as expected, with QUANTITY3 appearing as soon as MATERIAL3 is set:

(${MATERIALS3}!='PLEASE_ANSWER' and ${MATERIALS3}!=${MATERIALS2}) or (${MATERIALS3}!='PLEASE_ANSWER' and ${MATERIALS3}!=${MATERIALS1})

I've included a sample for you to look at.

Thanks

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Andrew,

Instead of creating two groupings, you should simple continue the 'and' sequence:

${MATERIALS3}!='PLEASE_ANSWER' and ${MATERIALS3}!=${MATERIALS2} and ${MATERIALS3}!=${MATERIALS1}

AndrewHargreaves2
Deactivated User

Thank you James Tedrick‌!

#SyntaxKing

0 Kudos