Conditional statement for select_one and select_multiple in report template

697
9
Jump to solution
05-07-2019 02:10 AM
Highlighted
Occasional Contributor

Hello,

Is it possible to integrate conditional statement for select_one and select_multiple fields in a report template for a Survey123 report ?

If yes, what is the synthax ?

If no, is it planned as a future feature and when is the release planned for ?

Thanks a lot,

Tags (2)
1 Solution

Accepted Solutions
Highlighted
Occasional Contributor

Hello, this works great in the XLSform to build the survey but not in the template for the report.

But I found the solution for the report template :

${if ((weather | selected: "other"))} The weather was ${weather_other}${/}

Have a good day !


View solution in original post

9 Replies
Highlighted
Esri Regular Contributor

Hello,

Select_one and select_multiple questions questions work the same as other question types when using if statement syntax in the report template.  So, for instance, let's say you have a select_one question with a field name of 'severity' that asks, "select severity of incident" and your choices are low, medium, high...the syntax would look like the following

${if severity=="high"}${followup_question}${/}

This will show the value from 'followup_question' only if 'high' has been selected for the preceding select_one question named severity.

Try this out and let me know if you have questions.

Best,

Brandon

Reply
0 Kudos
Highlighted
Occasional Contributor

Hello Brandon,

Thank you for the answer Brandon. I tried to replicate exactly your recommendation but it still doesn’t for me.

For instance, if I have :

 

type

name

select_multiple weather

weather_type

 

With the following choices :

 

list_name

name

label

weather

good

Beau

weather

rainy

Pluvieux

weather

cloudy

Nuageux

weather

other

Autre

 

And if I have in the report template :

${if weather_type=="other"} The weather was ${weather_other} ${/}

Unfortunately, the conditional statement doesn’t work.

Do you have any idea why this is happening ?

 

Best regards

Reply
0 Kudos
Highlighted
Esri Regular Contributor

Hello,

It looks like you have a space between ${weather_other} and $[/}.  Please remove this space, try again, and let us know your results.

Reply
0 Kudos
Highlighted
Occasional Contributor

Hello,

I made the change but it still doesn't work.

Do you have another hint ?

Best,

Reply
0 Kudos
Highlighted
Esri Regular Contributor

Can you please try this with a value different than 'other' and let me know your results?

Reply
0 Kudos
Highlighted
Occasional Contributor

I tried and unfortunately it still doesn't work.

Reply
0 Kudos
Highlighted
Frequent Contributor II

With select_multiple you have to use selected() not ==.

selected(${Customers},'Other')

https://community.esri.com/thread/184917-relevant-field-syntax-for-multiple-choice-questions 

Reply
0 Kudos
Highlighted
Occasional Contributor

Hello, this works great in the XLSform to build the survey but not in the template for the report.

But I found the solution for the report template :

${if ((weather | selected: "other"))} The weather was ${weather_other}${/}

Have a good day !


View solution in original post

Highlighted
New Contributor III

Hi Brandon,

I have a select_one question with 3 possible responses. This questions cues a text field for "description" if 2 of the 3 responses are selected. I'd like the feature report to do the same - show the description, but only if choice1 or choice2 are selected. How do I write the syntax to show the description for 2 of 3 selections from my select_one?

${if select_one|selected:"choice1,choice2"} doesn't give a syntax error, but doesn't show the value in the report.

${if select_one|selected:"choice1","choice2"} gives a syntax error.

${if select_one|selected:"choice1"}or${if select_one|selected:"choice2"} with ${/}${/} at the end to close both gives no syntax error, but only shows the word "or". If you remove the "or" you just get nothing.

Thanks for the help,

RyanE

Reply
0 Kudos