• Resolved kassupassu

    (@kassupassu)


    Hello,

    Am I doing something wrong.

    1) I have radio buttons “Yes” and “No” (fieldname5)
    2) I have also one numberfield (fieldname2)
    3) Then I have calculation field (fieldname1)

    I need a formula which I’m going to describe next.

    (fieldname2*0,5)-(fieldname5==’No’?100:200)

    That is easy part and It’s working. The problem is that if you choose “No” the calculated value must be 0 <= X => 2400. If you choose “Yes” the value must be 0 <= X => 4800.

    It’s OK, if calculator can’t calculate value between numbers. But it’s necessary that value not going to be over 2400 on “No” and not going to be over 4800 on “Yes”.

    I tried something like below, but calculator doesn’t work, so I’m doing something wrong. Everything is on Calculate field at “Set Equation”.

    If I need to use javascript, where I’m going to place the (function?

    —MIN(2400==fieldname5’Ei’?)(fieldname2*0.5)-(fieldname5==’Ei’?100:200)

    Best regards;
    Kasperi

Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @kassupassu,

    There are some issues in your current equation, but its implementation is really simple, and there are multiple alternatives:

    
    (function(){
        var max_value = 4800, additional = 200;
        if(fieldname5 == 'No')
        {
            max_value = 2400;
            additional = 100;
        }
        return MIN(fieldname2*0.5-additional,max_value);
    })()
    

    another alternative would be:

    
    MIN(fieldname2*0.5-((fieldname5 == 'No') ? 100: 200),((fieldname5 == 'No') ? 2400: 4800))
    

    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘If,Else or Min, Max problem’ is closed to new replies.