Support » Plugin: Calculated Fields Form » Multiple IF statements for one form?

  • Resolved Snucker0

    (@snucker0)


    This IF statement works:

    IF(AND(fieldname2 == 'C276', fieldname3 == '.250', fieldname4 == '26,063'), ".035"," ")

    I would like to include another IF statement in this equation for when fieldname4 = another value. The singular equation would be:

    
    IF(AND(fieldname2 == 'C276', fieldname3 == '.250', fieldname4 == '38,044'), ".049","”)

    This does not work:

    IF(AND(fieldname2 == 'C276', fieldname3 == '.250', fieldname4 == '26,063'), ".035","");
    IF(AND(fieldname2 == 'C276', fieldname3 == '.250', fieldname4 == '38,044'), ".049","”);

    Is there a specific way to write these two statements to have them both work?

    Thanks so much!

    • This topic was modified 2 months, 2 weeks ago by Snucker0.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @snucker0

    You have two alternatives:

    You can nesting the IF operations:

    IF(AND(fieldname2 == 'C276', fieldname3 == '.250', fieldname4 == '26,063'), ".035",IF(AND(fieldname2 == 'C276', fieldname3 == '.250', fieldname4 == '38,044'), ".049",""));

    Or you can use if conditional statements and function structure:

    (function(){
    if(AND(fieldname2 == 'C276', fieldname3 == '.250', fieldname4 == '26,063')) return 0.035;
    if(AND(fieldname2 == 'C276', fieldname3 == '.250', fieldname4 == '38,044')) return 0.049;
    
    return '';
    })()

    Best regards.

    Thread Starter Snucker0

    (@snucker0)

    Hi @codepeople ,
    Thank you so much for your quick response. Worked like a charm. I very much appreciated you providing both options.
    All the best

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.