Select to view content in your preferred language

Formatting if statements for relevant column: what are 'yes' and 'no?'

436
5
06-05-2023 03:19 AM
AnnaScholl
Occasional Contributor

I am new to excel syntax. I learned that the if statement should be formatted if(condition, a, b) as in the Esri docs screenshotted below. This is for the relevant field of a question. 

LydiaYoungblood_0-1685960134168.png

The problem is, it is unclear to me what this 'yes', 'no' is. Does this refer to my particular choice names? or is it a global variable? I want the if statement to be: if(condition, show the question, don't show the question). 

E.g. if my questions were about consent in the example screenshot, would I have: 

if(selected(${Q1_consent}, 'Yes, I consent') and selected(${Q2_incity}, 'Yes, I live in the city'), 'Yes, I consent', 'No, I do not consent')

...based on what I have in my choice tab? or would it be: 


if(selected(${Q1_consent}, 'Yes, I consent') and selected(${Q2_incity}, 'Yes, I live in the city'), 'yes', 'no')

 

0 Kudos
5 Replies
Nicole_Ueberschär
Esri Regular Contributor

'yes' is in this example the result for if the condition is true and 'no' the result if the condition is false.

For the correct if statement it is relevant what you have in the name column of your choice option. If the label says 'Yes, I consent' but the name says only 'yes', then I would assume you would like something like

if(selected(${Q1_consent}, 'yes') and selected(${Q2_incity}, 'yes'), 'Yes, I consent', 'No, I do not consent')

0 Kudos
AnnaScholl
Occasional Contributor

Hi @Nicole_Ueberschär Nicole, thank you. So it's in your example:
if(selected(${Q1}, 'choice_name') and selected(${Q2}, 'choice_name'), 'label_name', 'label_name')?

0 Kudos
Nicole_Ueberschär
Esri Regular Contributor

The output of the if statement is a simple string so you could put anything there. If you would like to use the labels of the selected options then you could use jr:choice-name(${Q1}, '${Q1}').

0 Kudos
JenniferAcunto
Esri Regular Contributor

I think you are getting lost in what an if statement is and not necessarily what you need. It sounds to me like you want a field to be relevant if ${Q1_consent} is 'Yes, I consent' and ${Q2_incity} is 'Yes, I live in the city'.

If that is the case and assuming that the actual choice names are 'yes', you would just need to add this in the relevant field: ${Q!_consent}='yes' and ${Q2}='yes'

How the relevant column works is that if what you put in it evaluates to true, then the field is 'relevant' and displayed, if it is not true, then it is not displayed. 

- Jen
AnnaScholl
Occasional Contributor

You were exactly right. In the end I thought I needed if statements as I had multiple criteria to run through. 

Ultimately I needed: (${Q1}='yes' and ${Q2}='yes_city') or (${Q1}='yes' and ${Q2}='no_not_incity' and ${consent_gdpr}='yes_gdpr').


 

 

 

 

 

0 Kudos