Survey123 Reports - Conditional display of text

1581
2
02-28-2022 01:19 PM
DianeCrookes
New Contributor

Hi,

I would like to know how to do 2 things using conditional statements in a Survey123 report

1. I would like to display a data item in the report only if it has a particular value. The data item is from a select_one list and the possible values are 'Fully Met', 'Partly Met' or 'Not Met'. So as an example, one of them is called 'RecreationSpaces' and I've tried the syntax below to only display if it has the value 'Not Met' but it doesn't work...

${if RecreationSpaces =="Not Met"}

Recreational Spaces: ${RecreationSpaces}

${/}

2. I'd also like to know if I can change the colour of text based on a value. So in the example above, colour the text green if the value is 'Fully Met'

I would really appreciate any advice or tips as its driving me a little bit mad 

Many thanks,

John

 

Tags (2)
0 Kudos
2 Replies
LeonardBarnhill
Occasional Contributor

Good morning,  based on what you have presented in your questions, I might try formatting the statement a little differently:  try selected(${RecreationSpaces}, 'Not Met') in the relevant column of the conditional statement line.  You can add multiple selected statements separated by or as in selected(${<fieldname>},'condition') or selected(${...)

Still working on the color portion of your question

0 Kudos
DerrickWestoby
Occasional Contributor III

This is for the feature report itself, not the XLS form, right? 

I believe that you need to use the NAME of your list choice, not the LABEL (but try both because I don't remember for sure) 


${if RecreationSpaces | selected:"fully_met"}${RecreationSpaces} ${/}

${if RecreationSpaces | selected:"not_met"}${RecreationSpaces} ${/}

Notice that I'm just changing the font color of the call to print out  your ${RecreationSpaces} value.  You can do this in  your feature report as well.  Background color, highlighting, text color ect will work this way (and I believe it's only the $ symbol you actually need to change)

edit: If you created your survey in the web designer, it may not be obvious to you that you have a name and label for your list options (or "Label" and "Code" when viewing in your AGOL Feature Layer details). 

Here's a few screenshots on where to find that, assuming you don't see your name/code values otherwise (note that in my example, the name and the code match exactly. I try to do this on purpose, but it's usually not going to be the case)

DerrickWestoby_2-1646241115393.png

 

DerrickWestoby_0-1646240947968.png

 

DerrickWestoby_1-1646240960326.png

 




0 Kudos