• Resolved stefaninthailand

    (@stefaninthailand)


    Hi,

    I wonder if it is possible to create this conditional logic with CFF:

    Field A is a calculated field – result = x
    Field B is a calculated field – result = y

    if x is greater than y = show A
    if y is greater than x = show B

    Sounds easy but I did not find a way to put fieldnames in dependencies.

    Thank you very much
    Stefan

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

    (@codepeople)

    Hello @stefaninthailand

    You have many options to use conditionals in the equations.

    You can use the “IF” operation:

    IF(fieldname1<fieldname2, fieldname2, fieldname1)

    You can use the ternary javascript operator:

    (fieldname1<fieldname2) ? fieldname2 : fieldname1

    You can use the “if” conditional statement in javascript (javascript is a case-sensitive language, please, do not confuse it with the “IF” operation), and function structure:

    (function(){
    if(fieldname1<fieldname2) return fieldname2;
    return fieldname1;
    })()

    However, in this specific case, you don’t need conditionals, only use the “MAX” operation:

    MAX(fieldname1,fieldname2);

    Note that fieldname1 and fieldname2 can be replaced by their respective formulas instead of using multiple calculated fields.

    For example, if the equation in the fieldname1 is fieldname3+fieldname4, and the equation of fieldname2 is fieldname5+fieldname6 (these are hypothetical equations and fields’ names, selected only to describe the process), instead of using two calculated fields for fieldname1 and fieldname2, you can implement everything in a unique calculated field:

    MAX(fieldname3+fieldname4, fieldname5+fieldname6)

    Best regards.

    Thread Starter stefaninthailand

    (@stefaninthailand)

    Great!

    Thank you very much for the fast and comprehensive answer. That was really helpful.

    Best regards
    Stefan

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘conditional: display the field with the higher result’ is closed to new replies.