Using conditions in the calculation widget

  • Profile Image
    info@pdfn.co
    Asked on March 11, 2016 at 07:23 AM

    Is it possible to output a fiksed value to a field, if calculation for it results in lower value? For example if a+b < 10, then output 10, if not output result for a+b

    Thank you.



    This is a re-post of a comment on Form Calculation - Math Function Reference

  • Profile Image
    Jan
    Answered on March 11, 2016 at 08:28 AM

    This is possible in JotForm. I'll get back to you once I'm done with demo and the instructions. Thank you for your patience.

  • Profile Image
    Jan
    Answered on March 11, 2016 at 09:08 AM

    Thank you for waiting. Here's a GIF animation of the result:

    Please check this demo form: https://form.jotform.me/60703187512451
    You can clone it if you like to study how it was build.

    Here are the steps on how I did this:

    1. I created 3 text boxes (A, B, and Output).

    2. I used the "Form Calculation" widget in order to calculate the total of A and B. 

    3. I created a formula that will add the field A and field B.

    4. I make sure that the default value of the calculation widget is "blank" and not 0.

    5. Now that we're done with the form fields, we can now apply conditions. Click the "Conditions" button in the toolbar. We'll be using the "Update or Calculate a field" condition.

    6. You need to create conditions where if the total of A+B is less than, it will put 10 in the Output field. If it is greater than 10, it will copy the total to the Output field.

    7. Here's the summary of 2 conditions.

    If the "Calculation" field is greater (>) than 10, then it will copy its value and put it on the "Output" field.

    If the "Calculation" field is less (<) than 10, then it will put "10" on the "Output" field.

    Related Guides:
    How-to-perform-calculation-in-the-form
    Smart-Forms-Using-Conditional-Logic

    Hope that helps. Let us know if you need further assistance. Thank you.