Assign Calculation and conditionally show a field based on users answer

  • Profile Image
    MD89
    Asked on August 13, 2025 at 3:55 PM

    I am creating a form where I would like to assign a value to each response, lets say A,B,C,D. At the end of the questionnaire I would like some logic in place to see which of those 4 occurred most frequently within the responses, so that I can make a recommendation to the respondent. How can I do this?

  • Profile Image
    Christian Ice JotForm Support
    Replied on August 13, 2025 at 4:38 PM

    Hi Michael,

    Thanks for reaching out to Jotform Support. I checked your form and I see that you set up a calculation values on each of the Single Choice element. When creating calculations in Form Calculation widget, it is designed to handle numeric calculations only.

    Assign numeric values like this:

    Option 11  (for A)
    Option 22 (for B)
    Option 33 (for C)
    Option 44 (for D)

    Then, use hidden Form Calculation widgets to count how many times each number appears and use conditional logic to show the recommendation based on the highest count.

    You can try to check my demo form and clone it if this is what you're looking for.

    Give it a try and let us know how it goes.

  • Profile Image
    MD89
    Replied on August 20, 2025 at 1:34 PM

    Hi Christian,

    It appears that the link to the demo form isn't working, would you be able to re-share it?

    Thanks,

    Michael

  • Profile Image
    Jan JotForm Support
    Replied on August 20, 2025 at 1:54 PM

    Hi Michael,

    Try this form link and see if the issue persists. Cloning an Existing Form From a URL is easy. Let me walk you through it:

    1. On your My Workspace page, click on Create on the top-left side of the page.

    2. Select Form from the assets, and then click on Import Form.

    Assign Calculation and conditionally show a field based on users answer Image 1 Screenshot 30

    3. In the next window, click on From a Web Page

    4. Paste the form link into the Enter URL field and click on Create Form.

    Assign Calculation and conditionally show a field based on users answer Image 2 Screenshot 41 After cloning the form, it will open in Form Builder automatically. You can now edit it the way you want and publish it.

    Give it a try and let us know if you need any other help.

  • Profile Image
    MD89
    Replied on August 20, 2025 at 2:42 PM

    Thanks, Jan. I was able to view the sample form. However, it doesn't appear to be working as expected. It looks like the calculator is just adding the values associated with each response and displaying this at the end. What I am looking to do is have the tool display the value that occurs most frequently. So in a scenario where someone selected the answer with a set value of 2 for both questions, the value displayed at the end of the form would be "2".


  • Profile Image
    Manilene JotForm Support
    Replied on August 20, 2025 at 3:11 PM

    Hi Michael,

    Can you confirm if the calculation should completely ignore the total sum and only focus on identifying the most frequently chosen value across all responses?

    Once we know more about what’s going on, we can figure out the fix.

  • Profile Image
    MD89
    Replied on August 20, 2025 at 3:14 PM

    Hi Manilene,


    That is absolutely the case - The values assigned to each response are just being used as identifiers. We just need to see which one occurs most frequently at the end of the form.


  • Profile Image
    Leona JotForm Support
    Replied on August 20, 2025 at 4:03 PM

    Hi Michael,

    I can see that your form already has Form Calculation widgets added. To achieve your goal of identifying which option occurs most frequently, you’ll just need to set up some Update/Calculate Field conditions that increment the counts for A, B, C, and D.

    1. In Form Builder, go to the Settings tab at the top. On the left panel, click Conditions.

    2. Click on Add Conditions and select Update/Calculate Field. Assign Calculation and conditionally show a field based on users answer Image 1 Screenshot 20

    3. For each question, set rules like this:

    IF Question is equal to A, DO Calculate A_Count + 1into A_Count
    IF Question is equal to B, DO Calculate B_Count + 1into B_Count
    IF Question is equal to C, DO Calculate C_Count + 1into C_Count
    IF Question is equal to D, DO Calculate D_Count + 1into D_Count

    4. Repeat the same logic for all your questions. Each time an option is selected, the corresponding count field will increase by 1.

    This way, instead of summing values, your form will track frequency and display the most common result. Do you want the form to display just the most frequent answer, like B, or also show counts for all options A=2, B=5, C=1, D=0? Should the recommendation be visible before submission or only on the Thank You page? If that’s not quite what you’re looking for, can you share a bit more info so I can help you better?

    As soon as we hear back from you, we can work on getting you a solution for this.


  • Profile Image
    MD89
    Replied on August 22, 2025 at 11:08 AM

    Thanks, Leona! I will try this on my end. I would like to display only the most commonly occurring answers.

  • Profile Image
    Adrian Besilla JotForm Support
    Replied on August 22, 2025 at 11:21 AM

    Hi Hi Michael,

    Since you’d like to display only the most commonly occurring answer, once you’ve set up the counters for A, B, C, and D, you’ll just need to add an extra condition like Show/Hide Field, to compare the counts and outputs only the option with the highest value. For example, if A_Count is greater than B_Count, C_Count, and D_Count → Show A in a separate Result field.

    Repeat similar conditions for each option B, C, D, so that only the top result will be displayed at the end of the form. This Result field can then be shown either on the form itself before submission or on the Thank You Page depending on your preference.

    Let us know if you need any more help.