How to use an IF statement with a number range

729
3
07-17-2020 12:49 AM
Mondi_GIS
Occasional Contributor

Hello all

I have a calculation that i need to do where I ask field workers to measure the height of seedlings. I have created a decimal field where they input their height in cm's. In the next line i have a hidden field where I now want to calculate whether the seedlings are between 25-45cm. If the height falls inside this range, they should get a 0 value, and if they are outside they should get a value of 1. I have used this if statement, but it doesn't seem to return the rigt value. It seems just to give me a zero.

if(${q2_1_2_height}>=25, 0,(if(${q2_1_2_height} <=45, 0, 1)))

I have other criteria that are just Yes/No answers, where the yes gets a zero and No a 1. I then add them all up to get a Pass/Fail according to certain criteria. This is the reason why i want to convert the height values to a zero or 1 as well so that i can sum them with the other questions

Please could I get some help

Thanks

0 Kudos
3 Replies
DavidPike
MVP Frequent Contributor

I'm no expert on this Arcade or 123 syntax btw.

though if it's on the basis of Condition, IfConditionTrueValue, ElseValue :

if (${q2_1_2_height} >= 25 and ${q2_1_2_height} <= 45, 0, 1)

Mondi_GIS
Occasional Contributor

I just figured it out. I had to try several different ways, but this eventually worked for me

if(${q2_1_1_height} >=  0 and ${q2_1_1_height} < 25, 1, if(${q2_1_1_height} >=  25 and ${q2_1_1_height} <= 45, 0, 1))

Thanks for the help

0 Kudos
DougBrowning
MVP Esteemed Contributor

No need for two if statements.  The post above is correct.