How to pass the highest selected number in a matrix to another field

  • Firemedic07
    Asked on November 16, 2016 at 10:35 PM

    I have a drop down style number selector 0-400 that there are multiple selections. I am looking to put the highest number selected in another field in my form. 

    Jotform Thread 991909 Screenshot
  • candy
    Replied on November 17, 2016 at 2:10 AM

    Hello,

    I have cloned your form in order to test it on my side. As I have understood your question, you have wanted to set a predefined value to the dropdown lists of the matrix. If so, as I have check it is not possible to set a predefined value to a matrix.

    What I do not understand is what do you mean by "I am looking to put the highest number selected in another field in my form." Which field in your form, do you want to set the highest number? In the matrix, or in the another field of your form?

    Could you please explain your question further?

    Waiting for your response.

    Thanks in advance.

  • Boris
    Replied on November 17, 2016 at 8:31 AM

    This is possible by using our insert/calculate type conditions, but it may appear to be tedious when setting it up. Basically, we will use conditional logic to pass a value from the Matrix field to your desired Text Box field:

    https://www.jotform.com/help/268-How-to-Insert-Text-or-Mathematical-Calculation-into-a-Field-Using-Conditional-Logic

    You can see a demo form of this functionality here:

    https://www.jotformpro.com/form/63213632639960

    Now, in order to achieve that requirement, we will perform several steps. please make sure to follow the steps correctly in order for the calculation to work the way you asked.

    1. We should add an insert/calculate condition to your form. We will set it up so that "IF Matrix field is filled, DO calculate a field's value", and then click on the ... button to add a mathematical function:

    How to pass the highest selected number in a matrix to another field Image 1 Screenshot 90

    2. Add the max() function:

    How to pass the highest selected number in a matrix to another field Image 2 Screenshot 101

    3. Place your cursor inside the max() function, which means inside its brackets ( and ), and then click on the Add Field button:

    How to pass the highest selected number in a matrix to another field Image 3 Screenshot 112

    4. Select the Matrix field, and then make sure to select all its checkboxes that appear, and then its Done button:

    How to pass the highest selected number in a matrix to another field Image 4 Screenshot 123

    5. Now comes the trickiest part. The above steps have left us with all the individual rows of the Matrix field inside the max() function, but now we need to separate the fields with a mathematical comma. This is how the calculation looks at the start of step 5:

    How to pass the highest selected number in a matrix to another field Image 5 Screenshot 134

    Now, you need to click between each and every two rows, and add a comma in between:

    How to pass the highest selected number in a matrix to another field Image 6 Screenshot 145

    This has separated each row with a comma, but if the background of the comma is light gray, it means the comma is literal text, and not a mathematical one.

    6. In order to change each comma to a mathematical one, simply click on the comma until it gets the same dark background as the 0-9 numbers have:

    How to pass the highest selected number in a matrix to another field Image 7 Screenshot 156

    7. Finally, complete the condition by selecting the "Summary" field where it will forward this calculated value, and click on Save:

    How to pass the highest selected number in a matrix to another field Image 8 Screenshot 167

    This should leave you with the same functionality that is demonstrated in the form linked above. Please try it out, and let us know should you run into any snags along the way or if you need further assistance setting it up. :)

  • Firemedic07
    Replied on November 20, 2016 at 4:15 PM

    Worked awesome. What would i have to do differnt if I wanted to use a Numeric Text Box instead of the Drop Down?

  • jonathan
    Replied on November 20, 2016 at 5:40 PM

    You meant you want to use Numeric textbox as the input type in your Matrix table field?

    You can go ahead and change it in the Matrix table option in the toolbar...

    How to pass the highest selected number in a matrix to another field Image 1 Screenshot 30

    The functionality should still work as can be test on this form https://form.jotform.com/63246397528971

    How to pass the highest selected number in a matrix to another field Image 2 Screenshot 41

    Let us know if you need further assistance.

     

     

  • Firemedic07
    Replied on November 20, 2016 at 5:49 PM

    When i do that and enter 1-11 in the fields it enters 111 on the other field

     

  • jonathan
    Replied on November 20, 2016 at 6:18 PM

    Can you please describe more how to produce that issue.

    I test the form https://form.jotform.com/63246397528971 but I could not see it.

    How to pass the highest selected number in a matrix to another field Image 1 Screenshot 20

     

     

  • Firemedic07
    Replied on November 20, 2016 at 6:39 PM

    How to pass the highest selected number in a matrix to another field Image 1 Screenshot 30

     

    How to pass the highest selected number in a matrix to another field Image 2 Screenshot 41

    This is what happens when I put numbers in. 

  • Firemedic07
    Replied on November 20, 2016 at 8:19 PM

    Figured it out. Thank you all.