• Resolved coolwen22

    (@coolwen22)


    Hi! First of all, awesome plugin and support you are giving here!

    I wish to exclude some fields from the calculation if the field beside them are empty. How can I achieve this?

    Example:

    fieldname1 — fieldname2
    fieldname3 — fieldname4

    Fieldname2 and fieldname4 should be excluded from the calculation if fieldname1 and fieldname3 are empty.

    Hope I make this clear. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @coolwen22

    Thank you very much for using our plugin. The code to use depends on the equation you want to implement. I’ll try to describe the process with two hypothetical examples.

    Assuming you have the equation:

    fieldname2+fieldname4+fieldname9+fieldname10

    And you want to exclude the fieldname2 and fieldname4 from the sum if fieldname1 and fieldname3 are empty, respectively.

    The equation can be implemented as follows:

    IF(fieldname1|r == '', 0, fieldname2)+IF(fieldname3|r == '', 0, fieldname4)+fieldname9+fieldname10

    The equation includes the IF operation and checks the raw values of fieldname1 and fieldname3 by using the |r modifier. In this first example, the alternative value is the number zero because it does not modify the sum result.

    Now, if we use the multiplication instead of the sum operator:

    fieldname2*fieldname4*fieldname9*fieldname10

    The zero is not an alternative in this case because affects the result. The modification in this case would be:

    IF(fieldname1|r == '', 1, fieldname2)*IF(fieldname3|r == '', 1, fieldname4)*fieldname9*fieldname10

    Now the alternative value is the one.

    Best regards.

    Thread Starter coolwen22

    (@coolwen22)

    Works like a charm! Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Exclude field from calculation’ is closed to new replies.