Is it possible to test multiple conditions and return a value based on the result. In Excel this can be done with nested IF statements (among others). Is something like this possible in Tapforms? For example: If(Field;”Spring”;”10″) or If(Field;”Summer”;”20″) or If(Field;”Fall”;”30″)
Hi Mackay,
Yes, you can do this in a Tap Forms formula. But it’s much easier to deal with in a Script field rather than a Calculation field.
Your example though doesn’t quite make sense because there’s no condition in the first parameter.
You need to compare Field with something.
For example:
IF(Field = 10; "Spring"; IF(Field = 20; "Summer"; IF(Field = 30; "Fall"; "")))
So if field is 10, return Spring, otherwise if field is 20, return Summer, otherwise if field is 30, return Fall, otherwise return the empty string.
But in a Script, it would look like this:
if (field == 10) {
return "Spring";
} else if (field == 20) {
return "Summer";
} else if (field == 30) {
return "Fall";
} else {
return ""
}
To me that’s just easier to read than the nested IF()
function.
You can also use a switch
statement, which might look nicer.
Thanks,
Brendan
Here’s a simple example I use to test pay codes
IFEQUAL([PayCode];”EFT”;[Premium]*12;IFEQUAL([PayCode];”Annual”;[Premium];IFEQUAL([PayCode];”Qrt”;[Premium]*4;IFEQUAL([PayCode];”Semi”;[Premium]*2;0))))