Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Using Tap Forms 5 › Calculation to insert a number based on other field’s text
- This topic has 5 replies, 2 voices, and was last updated 8 months, 1 week ago by
Brendan.
-
AuthorPosts
-
April 1, 2025 at 5:06 AM #51764
phloemParticipantField “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 8 months, 3 weeks ago by
phloem.
April 4, 2025 at 8:57 AM #51781
BrendanKeymasterThe
IF()function is used for comparing numbers. TheIFEQUAL()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
April 11, 2025 at 8:06 AM #51825
phloemParticipantGreat 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 8 months, 2 weeks ago by
phloem.
April 11, 2025 at 8:12 AM #51827
phloemParticipantwould it be like this?
IFEQUAL([Location]; “Maya”; 22; IFEQUAL([Location]; “ABS”; 27; IFEQUAL([Location]; “Tom”; 15; 0)))
April 11, 2025 at 1:27 PM #51828
phloemParticipantYes. this is working
April 11, 2025 at 9:31 PM #51834
BrendanKeymasterGlad 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.
-
This topic was modified 8 months, 3 weeks ago by
-
AuthorPosts
You must be logged in to reply to this topic.