I hope to get some help, tried many things but cannot get it working.
What I want is to add or substract two numeric fields depending on a third (text) field.
Field1: numeric value
Field2: numeric value
Field3: text (“add” or “substract”)
Field4: this field (calculation field)
This Calculation formula should work I think:
IF(Field3=”add”;Field4=Field1+Field2;Field4=Field1-Field2)
I set Field4 to ‘numeric’
What is wrong? (because this doesn’t work….)
Try this: IF(Field3=”add”;Field1+Field2;Field1-Field2)
Thanks Daniel, but that didn’t work either.
It looks like its not possible to mix txt and num fields in calculation. I found a workaround:
IF(LENGTH(Field3)=3;Field1+Field2;Field1-Field2)
Now all variables are numeric and this does work :-)
The IF()
function is for numbers only. At least the comparison part is. To compare strings, you have to use the IFEQUAL(X; Y; A; B)
function.
Also you can’t and shouldn’t access the current Calculation field within the formula. You would cause an infinite loop by doing that and Tap Forms will crash.
Ah, that explains, Brendon and Daniel for helping me out.