How to get the highest value of the selected multiple choice field options?

  • Profile Image
    scottlawley
    Asked on March 08, 2021 at 07:53 AM

    Hi Support Team,

    I have a form with a multiple choice widget, and I have assigned calculation values to each of the choices. I would like to do the following computation:

    max(WIDGET) / count(WIDGET)

    I want the max function to return the highest value of the selected choices, and I want the count function to return the number of selected choices from the multiple choice widget.

    I have tried doing this, but the max seems to return the sum of the selected choices. Is this a bug, or am I trying to do something erroneous?

    Please advise.

    Regards,

    Scott

  • Profile Image
    Nik_M
    Answered on March 08, 2021 at 09:34 AM

    That is not a bug. The max() is used to return the highest value when comparing multiple fields.

    As a solution, you can add a hidden number field for each multiple choice field option and set conditional logic to pass the values to the Number fields. You can then compare the values that are passed to the number fields with the max() function.

    1615213776_604634d018516_valueslogic.PNG

    1615213785_604634d92e43c_valuemax.PNG

    Related Guides:

    How to Insert Text or Calculation into a Field Using Conditional Logic

    Form Calculation - Math Function Reference

    Demo form: https://form.jotform.com/210663871781057


  • Profile Image
    scottlawley
    Answered on March 08, 2021 at 12:31 PM

    Hi.

    Thanks for the response. This is disappointing. Afterall, what good is the multiple choice widget if the values cannot be interrogated? If I have to setup hidden fields, then why have a multiple choice in the first place. Also, my form has approximately 40 multiple choice widgets. The approach you outlined is impractical.

    Is there a way to derive the max in a Table? Is there some other type of transformation I can do to get to the information I need without having to introduce additional fields on the form?

    Thanks,

    Scott

  • Profile Image
    Nik_M
    Answered on March 08, 2021 at 02:53 PM

    Hi Scott,

    You can use the Input Table field. This wouldn't require additional fields.

    1615233117_6046805d8b442_inputtable.PNG

    Related Guide: How to Perform Form Calculation in the Input Table Field?

    Demo form: https://form.jotform.com/210663871781057

  • Profile Image
    scottlawley
    Answered on March 08, 2021 at 06:47 PM

    Nice. Thanks for this. I will give it a try.

  • Profile Image
    scottlawley
    Answered on March 09, 2021 at 07:01 AM

    Hmmm just trying it now. Yes, I can get the max, but I cannot get the number of selected choices. The count() function doesn't seem to work on this widget.

    After reviewing this alternative solution, I still feel that the multiple choice widget is the most elegant solution from an end-user perspective. The input table widget has limitations from a styling perspective. I hope that the Jotform product team will consider improving the multiple choice widget in the near future.

    Thanks,

    Scott

  • Profile Image
    Zahra_S
    Answered on March 09, 2021 at 08:50 AM

    Hi there!

    We apologize for the inconvenience.

    I have tested the max() function in various scenarios like Input Table, Multiple Choice, with and without calculation values.

    The max() function is used to get the highest number added by the user in a numeric field. It looks like the max() function only works with number form fields, that's how it is built. We cannot get the highest value of selected options with this function.

    Demo Form: https://www.jotform.com/form-templates/find-the-highest-value

    The only workaround I can think of is the one suggested by my colleague. I know it is not ideal for you. Unfortunately, can't suggest you anything else right now.

    I will forward this as a feature request to our developers. However, we can't give an ETA if or when this will be implemented. You will be notified on this thread when there is an update.

    Feel free to contact us if you need further assistance.