Field “location” has a pick list. Each location has a known kilometer distance.
I want a calculation field to give a number depending on the “location”. For example, the calculation field will insert “27” when the location is “ABS”. If the location is “Miya”, then “22” will be inserted.
I’ve tried the if and if equal but I can’t get it to work. What should the equation be for the above example?
-
This topic was modified 4 weeks, 1 day ago by
phloem.
The IF()
function is used for comparing numbers. The IFEQUAL()
is for comparing text.
IFEQUAL([Location]; "Miya"; 22; 0)
So for your Location field, if it’s equal to “Miya”, the number 22 will be returned, otherwise 0 will be returned.
Set the Result Type to Number. Unless you want the text version of 22 or 0 to be returned, in which case you would set the Result Type to Text and use quotes around the numbers:
IFEQUAL([Location]; "Miya"; "22"; "0")
P.S. the []
around the field names are just to denote they’re fields and not text. Unless you’re writing it on iOS in which case you type it in exactly like that. On macOS you just double-click on a field to insert it into your formula.
Thanks,
Brendan
Great thank you. Ok. What should the calculation needs to includes multiple “if”. For example, if “Maya” then 22, if “ABS” then 27, if “Tom” then 15, otherwise 0?
-
This reply was modified 2 weeks, 5 days ago by
phloem.
would it be like this?
IFEQUAL([Location]; “Maya”; 22; IFEQUAL([Location]; “ABS”; 27; IFEQUAL([Location]; “Tom”; 15; 0)))
Glad you got it working. With the Calculation field, it can get pretty tricky to follow all the nesting. IF / THEN / ELSE, and so on.
That’s why when things get complicated like that, using a Script is much simpler I feel.