Survey123 Connect Nested Formula for Values

705
2
Jump to solution
08-06-2020 01:08 PM
by Anonymous User
Not applicable

I believe I have a fairly straight forward nested 'if' statement here, but I'm missing something as I keep receiving errors. Any help would be appreciated. Thanks! Any thoughts James Tedrick?

Here is the expression within a calculate field type. The field name is {risk_rating_calculate}:

if(${percent_rating}>=80,'SUSTAINABLE', if(${percent_rating}<80 and >=50,'AT RISK', if(${percent_rating}<50,'NOT SUSTAINABLE','')))

The error being thrown is this: 

Survey123 Connect Nested If Statement error

{percent_rating} is an integer field that references a previous calculate expression (see attachment screenshot).

Thanks in advance!

-Corey

0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

This seems to come up a lot.  With an and or or you have to give it the entire expression with field name not just a second value.  You can combine anything not just multiple values so need to be explicit.  Also you do not need the last if since it is the only option left (unless you have something else going on).

if(${percent_rating}>=80,'SUSTAINABLE', if(${percent_rating}<80 and ${percent_rating} >=50,'AT RISK', 'NOT SUSTAINABLE'))

Hope that helps

View solution in original post

2 Replies
DougBrowning
MVP Esteemed Contributor

This seems to come up a lot.  With an and or or you have to give it the entire expression with field name not just a second value.  You can combine anything not just multiple values so need to be explicit.  Also you do not need the last if since it is the only option left (unless you have something else going on).

if(${percent_rating}>=80,'SUSTAINABLE', if(${percent_rating}<80 and ${percent_rating} >=50,'AT RISK', 'NOT SUSTAINABLE'))

Hope that helps

by Anonymous User
Not applicable

Thank you, Doug Browning! This works perfectly 🙂

Just the answer I was looking for. Thank you for your insight regarding this expression and your quick response! I was running into a wall on this one and you saved me some valuable time. Much appreciated!

Corey

0 Kudos