• Resolved mira404

    (@mira404)


    Hi, I just make a calculator and this gives me five different values. But I just need the lowest value for this calculation, so how to find out the lowest value?

    • This topic was modified 3 years, 11 months ago by mira404.

    The page I need help with: [log in to see the link]

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

    (@codepeople)

    Hello @mira404

    I’ll try to describe the process with a hypothetical example. Assuming you have five numbers or calculated fields, fieldname1, fieldname2, fieldname3, fieldname4, and fieldname5. And you want to get the minimum value. Insert a calculated field and enter the following equation in its settings:

    min(fieldname1, fieldname2, fieldname3, fieldname4, fieldname5)

    Similarly exists the max operation to get the maximum value:

    https://cff.dwbooster.com/documentation#mathematical-module

    Best regards.

    Thread Starter mira404

    (@mira404)

    Thanks it’s working

    Thread Starter mira404

    (@mira404)

    It’s working but I also need custom JS codes if possible please give me.

    Plugin Author codepeople

    (@codepeople)

    Hello @mira404

    Could you please be more specific?

    Best regards.

    Thread Starter mira404

    (@mira404)

    ok, I have another website and on that website I use Fluent Forms. At this moment not possible to shift to CFF.

    It gave me five different answers for 5 different calculations. Like this: https://weekendgolf.co/calculator/golf-handicap-index/ (second calculator)

    But I need to find out the lowest value for this calculation, so how to find out the lowest value?

    I contact their support but they told me

    Unfortunately, this is not possible using Fluent Forms. But you can do that using custom JS codes in fluent forms. Here is the sample code link that you can use as per your requirements.
    https://stackoverflow.com/questions/8934877/obtain-smallest-value-from-array-in-javascript.

    I don’t have any js knowledge.

    Plugin Author codepeople

    (@codepeople)

    Hello @mira404

    I’m not sure about your question, but I assume you are referring to the equation:

    PREC(min(fieldname6, fieldname26, fieldname21, fieldname16, fieldname11), 1)

    Your equation is correct, but I guess you want to ignore the empty fields. That increases the complexity of the equation because it requires you to check the fields one by one.

    Please, edit the equation as follows:

    
    (function(){
    var fields = [];
    if(fieldname6|r != '') fields.push(fieldname6);
    if(fieldname26|r != '') fields.push(fieldname26);
    if(fieldname21|r != '') fields.push(fieldname21);
    if(fieldname16|r != '') fields.push(fieldname16);
    if(fieldname11|r != '') fields.push(fieldname11);
    
    return PREC(IF(fields.length, min(fields), 0), 1);
    })()
    

    Best regards.

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

The topic ‘Find minimum value’ is closed to new replies.