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
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."
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.
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
look here: Cascading and external selects—Survey123 for ArcGIS | ArcGIS
download sample data here: https://www.arcgis.com/home/item.html?id=ac1d259587fa4c2d8c6356b67140a02d
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
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:
type | name | label | hint | appearance | relevant |
select_one ChoicesYesNo | Question1 | Question 1 | horizontal | ||
select_one ChoicesYesNo | Question2 | Question 2 | horizontal | ||
select_one ChoicesYesNo | Question3 | Question 3 | horizontal | ||
text | RelevantQuestionA | Relevant Question A | Displays if all 3 questions equal No | ${Question1} = 'No' and ${Question2} = 'No' and ${Question3} = 'No' | |
text | RelevantQuestionB | Relevant Question B | Displays if any of the 3 questions equal No | ${Question1} = 'No' or ${Question2} = 'No' or ${Question3} = 'No' | |
text | RelevantQuestionC | Relevant Question C | Displays 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.
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
Hi Andrew,
Instead of creating two groupings, you should simple continue the 'and' sequence:
${MATERIALS3}!='PLEASE_ANSWER' and ${MATERIALS3}!=${MATERIALS2} and ${MATERIALS3}!=${MATERIALS1}
Thank you James Tedrick!
#SyntaxKing