Calculation field IF(X;Y;Z)

Viewing 4 reply threads
  • Author
    Posts
  • January 22, 2020 at 6:21 AM #39323

    Hans
    Participant

    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….)

    January 22, 2020 at 9:36 AM #39325

    Daniel Leu
    Participant

    Try this: IF(Field3=”add”;Field1+Field2;Field1-Field2)

    January 22, 2020 at 9:54 AM #39326

    Hans
    Participant

    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 :-)

    January 22, 2020 at 2:56 PM #39332

    Brendan
    Keymaster

    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.

    January 23, 2020 at 4:26 AM #39341

    Hans
    Participant

    Ah, that explains, Brendon and Daniel for helping me out.

Viewing 4 reply threads

You must be logged in to reply to this topic.