Select to view content in your preferred language

Help with nested if statement

637
5
11-04-2022 09:03 AM
Hammers211
New Contributor III

Hello all! I am in need of help with understanding how to create a nested if statement. I have 3 statements:

if(${FIA1_Pass} = 'Pass','<font color="green">Pass</font>','')

if(${FIA1_Incorrect_Calc} >= 4,'<font color="red">Fail</font>','')

if(string-length(${Firm_Name_FIA1})=0, 'Incomplete','')

Currently I have them all in 1 calculation using the "or" function, and it works as I would expect in connect, however in my dashboard it appears as "true" or "false." I'm assuming I need to nest my if statement, correct?

 

Thank you for any help!

0 Kudos
5 Replies
jcarlson
MVP Esteemed Contributor

You've posted in the Survey123 space, but it sounds like you're trying to use this expression in Dashboards in some way? Can you clarify how you're trying to implement this expression?

- Josh Carlson
Kendall County GIS
Hammers211
New Contributor III

Hi Josh,

I'm using it in my XLS. 

0 Kudos
jcarlson
MVP Esteemed Contributor

In XLS, the general practice is to nest additional conditions in the last parameter of the preceding condition. The order matters, so make sure the most important condition is checked first.

if(condition, 'result', if(condition2, 'result2', if(condition3, 'result3', '')))

Using "or" is going to return a boolean, which is why you see true / false.

- Josh Carlson
Kendall County GIS
Hammers211
New Contributor III

This was very helpful, thank you! I was able to get it working.

 

Edit: It's partially working. In connect, it functions as expected, however in my dashboard, nothing is displayed.

0 Kudos
Hammers211
New Contributor III

When choosing the order...

If the first conditions evaluates to true, then the expression stop evaluation at that point correct? So the only way the last expression will be evaluated is if the first two are false? Is that correct?

0 Kudos