• Resolved 83creative

    (@winnard)


    Hi guys,

    Great plugin. I am trying to figure out a solution to my current calculated form.

    I have the current formula working in my form.

    (fieldname3*fieldname10)+(fieldname1+fieldname6+fieldname8+fieldname12)

    This works great. What I want to achieve is an if statement on the first part of the formula.

    Fieldname3 is where user enters purchase price of a house property.
    Fieldname10 is a dropdown set with the following options.

    < £125,000 = 0%
    > £125,000 < £250,000 = 1%
    > £250,000 < £500,000 = 3%
    > £500,000 < £1,000,000 = 4%
    > £1,000,000 < £2,000,000 = 5%
    > £2,000,000 = 7%

    I would like to do a formula whereby I can remove these options from the user side and the calculation works when the user enters the house value in Fieldname3. Is this possible? If so could somebody help me out??

    So it would be

    if ((fieldname3 < £125,000) * 0.00) +(fieldname1+fieldname6+fieldname8+fieldname12) and so on to cover the other %.

    If anybody could help me it would be most appreciated.

    Thanks

    Dan

    https://www.ads-software.com/extend/plugins/calculated-fields-form/

Viewing 3 replies - 16 through 18 (of 18 total)
  • Plugin Author codepeople

    (@codepeople)

    Hi,

    Yes, the equation can be configured just like you want. I can’t tell you exactly how because I don’t know that you pretend calculate, but if you have, for example, the radiobutton fieldname4 with three possible options: ‘value1’, ‘value2’, ‘value3’, the final equation should be modified in the following way:

    (function(){
    var v;
    var w;
    if(fieldname3 < 125000) return 100;
    if(fieldname3 >= 125000 && fieldname3 < 250000) v = 0.01;
    if(fieldname3 >= 250000 && fieldname3 < 500000) v = 0.03;
    if(fieldname2 < 125000) return 200;
    if(fieldname2 >= 125000 && fieldname3 < 250000) w = 0.04;
    if(fieldname2 >= 250000 && fieldname3 < 500000) w = 0.06;

    if( fieldname4 == ‘value1’){
    // … return the value corresponding
    }
    if( fieldname4 == ‘value2’){
    // … return the value corresponding
    }
    if( fieldname4 == ‘value3’){
    // … return the value corresponding
    }
    })()

    If you hide a field and this field is part of the equation, its value will be used in the equation result.

    Thanks for that, nearly what I require. The return formula for one of the values is:

    return prec(((fieldname3*v/100)+(fieldname2*w/100)),2);

    However if both fiedname2 and fieldname 3 are < 125000, I need the formula to sum these two retruned fixed values?

    Plugin Author codepeople

    (@codepeople)

    Hi,

    Please, follows the same structure of previous equations to check the values of fieldname2 and fieldname3 and return the correct value in that case.

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘Struggling with formula that requires if statement’ is closed to new replies.