Form Calculation: Turn negative result to zero

  • fincalosbalcones
    Asked on April 26, 2014 at 4:58 PM

    SPANISH QUESTION:

    Qué función matemática puedo usar en un campo calculado en una forma de cálculo para que si el el resultado es negativo la función lo cambie a cero.

     

    ENGLISH QUESTION:

    What mathematical function can be used in a calculated field in a calculation form (Widget) so that if the result is negative the function change it to zero.

     

    I will appreciate your help.

    Thanks.

  • Elton Support Team Lead
    Replied on April 26, 2014 at 8:14 PM

    Hi,

    We do not have this function available in the calculation wizard. Let me add this as a feature request as I find it useful. Hopefully our developer will be able to consider this in the future implementation.

    As for now, what you can do is to take your form source code and apply custom script that turns negative result to zero. If you need assistance with this, let us know and we'd be happy to provide you a walkthrough.

    Regards!

  • fincalosbalcones
    Replied on April 26, 2014 at 8:26 PM

    Thanks a lot for your quickly respond, I would like apply script that turn negative results to zero in some calculation fields in my forms. I will really appreciate your support.

  • jonathan
    Replied on April 26, 2014 at 10:50 PM

    Hi,

    You can also use the Math function max() -- it has a parameter like this max(0, n).

    Using max() the negative number can be round-up to zero(0).

    Test this form http://form.jotform.me/form/41159141656454? , make the result negative by subtracting 2nd number as higher than 1st number like this

    Form Calculation: Turn negative result to zero Image 1 Screenshot 30

    In my test form, the condition I setup is like this

    Form Calculation: Turn negative result to zero Image 2 Screenshot 41

     

    Please tell us if this will work on what you need and we will also assist you apply this on your form.

    Thanks.