Conditional statement for select_one and select_multiple in report template

2741
10
Jump to solution
05-07-2019 02:10 AM
Environnement_1Lausanne
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
Environnement_1Lausanne
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

10 Replies
BrandonArmstrong
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

0 Kudos
Environnement_1Lausanne
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

0 Kudos
BrandonArmstrong
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.

0 Kudos
Environnement_1Lausanne
Occasional Contributor

Hello,

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

Do you have another hint ?

Best,

0 Kudos
BrandonArmstrong
Esri Regular Contributor

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

0 Kudos
Environnement_1Lausanne
Occasional Contributor

I tried and unfortunately it still doesn't work.

0 Kudos
DougBrowning
MVP Esteemed Contributor

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 

0 Kudos
Environnement_1Lausanne
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 !


ryanEvanczyk
Occasional Contributor

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

0 Kudos