How to perform advance calculation and validation on matrix field?

  • drishtee_
    Asked on February 7, 2017 at 2:00 AM
    I have the same query. Please help.
  • Charlie
    Replied on February 7, 2017 at 2:25 AM

    You cannot use the specific cell in the matrix field in the "IF" statement of the conditions. What you can do is pass the total calculated value in a separate text box or form calculation widget and use that in your conditions as the validation. 

    1. Below are guides to help you get started on doing calculations in your matrix field:

    https://www.jotform.com/help/343-How-to-Perform-Form-Calculation-in-the-Matrix-Field 

    https://www.jotform.com/help/414-How-to-Perform-Calculation-in-the-Matrix-Field-Through-Condition 

     

    2. Now to do that validation, here I setup a "Text" field as the warning message:

    How to perform advance calculation and validation on matrix field? Image 1 Screenshot 30

     

    3. I then setup a conditional logic wherein I will hide the submit button and show the "Text" field if the total value is less than 100. 

    How to perform advance calculation and validation on matrix field? Image 2 Screenshot 41

     

    4. Here's a sample form that I made to see how it work. 

    https://form.jotform.com/70371139777968 

     

    I hope that helps. If I misunderstood your concern, please do provide us more details. 

  • drishtee_
    Replied on February 7, 2017 at 2:40 AM

    Thanks for the reply. Yes, you understood my doubt correctly.

    But the issue is that we have 3 columns which need validation. If we use 3 form calculation widgets with 3 different messages, it will confuse our customer.

    In order to make it easy, we can make a cell in the matrix which shows the total and have a validation error by changing the color of 'total cell' to red (rather than a message), it will not confuse the customer.

    I know how to do the total in a matrix, but I don't know how to do validation in the cell of the matrix.

    Please guide. Thanks

  • Ashwin JotForm Support
    Replied on February 7, 2017 at 3:31 AM

    Hello drishtee_,

    Can you please explain the validation condition on how you want to calculate the value of all the three columns of matrix field? Please explain your requirement a bit more in detail and we will try to help you if it is possible to achieve your requirement with one single calculation widget.  

    We will wait for your response.

    Thank you!

     

  • drishtee_
    Replied on February 7, 2017 at 3:42 AM

    Vegetable basket subscription model

    a. customer is asked to enter number of family members (basket is designed on the basis of number of family members - 500 gm per family member per day)

    b. the basket is delivered every mon-wed-fri

    c. the customer has to plan for the entire week in advance

    d. Row - name of vegetable, Column - Mon-Wed-Fri

    e. customer can choose any vegetable in any quantity and plan the basket, but the total quantity shouldn't exceed 500 gm per family member per day

    Link - https://form.jotform.me/63612568159463

  • Chriistian Jotform Support
    Replied on February 7, 2017 at 3:53 AM

    Hi,

    I'm currently checking your requirement. Please allow me some time to further investigate. I'll get back once I've found results.

    Regards

  • Chriistian Jotform Support
    Replied on February 7, 2017 at 4:31 AM

    As per further checking, I think the requirement would best achieve by creating 3 Form Calculation Widgets as it should evaluate that the family shouldn't exceed 500 gm per day.

    How to perform advance calculation and validation on matrix field? Image 1 Screenshot 30

     

    For example, If every column has a total greater than 500 then set the condition to hide the Submit button.

    How to perform advance calculation and validation on matrix field? Image 2 Screenshot 41

     

    Please let us know if you need further assistance.
    Regards

     

  • drishtee_
    Replied on February 7, 2017 at 4:38 AM

    The value is not fixed. It is dependent upon the input by the customer. If customer enters 1, the value is 500, if customer enters 2, value should be 1000, if customer enters 3, value should be 3000. Can't this be in cell matrix itself.

  • Charlie
    Replied on February 7, 2017 at 5:05 AM

    I'm sorry, I'm quite confused with your calculation. What is entered on the matrix field? Is it quantity of items OR grams? If you could give us a complete example with calculation then that would help us.  

    Note that you cannot assign direct value on your matrix field, you also cannot make a validation on a specific cell on your matrix field. 

    The only way I see this is possible is by recreating the matrix field into separate text boxes, radio buttons, check boxes, drop down and other default form fields that can be use in the conditional logic. 

    I suggest checking the following links that would help you make further calculation and advance setup:

    Conditional Logic: https://www.jotform.com/help/57-Smart-Forms-Using-Conditional-Logic 

    Conditional logic to perform calculation: https://www.jotform.com/help/268-Conditional-Logic-Inserts-Text-Calculation-Into-A-Field 

    Calculation using widget: https://www.jotform.com/help/259-How-to-Perform-Form-Calculation-Using-a-Widget 

    Assigning calculation value on fields: https://www.jotform.com/help/301-How-to-Assign-Calculation-Value 

     

    I hope that helps. 

  • drishtee_
    Replied on February 7, 2017 at 6:19 AM

    Please refer the link - https://form.jotform.me/63612568159463

    In the link,

    a. first, a customer enters the 'no. of family members'

    b. on the second page, a matrix appears, which has the quantity of potato & tomato calculated on the basis of a formula assigned to the same cell. The customer can also change the potato or tomato quantity as desired

    c. In the last cell, the total of the potato quantity and tomato quantity is calculated.

    d. We want that total to be ('no. of family members' x 500). If that's not the case, the form shouldn't submit.

  • candy
    Replied on February 7, 2017 at 7:13 AM

    Hello,

    I've tested your form and cloned it on my side in order to test it. Firstly, be aware of that you have too many missing conditions and you have added an autoresponder email but you do not request any email from your users. So, your autoresponder email has wrong settings.

    Related to your questions:

    a. first, a customer enters the 'no. of family members'

    As I have seen you have already set this calculation correctly with conditions.

    Also, you can use a drop-down list instead of a textbox for "no. of family members" field. So that, you can set calculation values easily as you can see the screenshot below:

    How to perform advance calculation and validation on matrix field? Image 1 Screenshot 40

    b. On the second page, a matrix appears, which has the quantity of potato & tomato calculated on the basis of a formula assigned to the same cell. The customer can also change the potato or tomato quantity as desired.

    As I've seen you've already done this with conditions. If you have any problem, for detailed information, please check the following guide: https://www.jotform.com/help/343-How-to-Perform-Form-Calculation-in-the-Matrix-Field 

    c. In the last cell, the total of the potato quantity and tomato quantity is calculated.

    As I have seen you've already done this by adding a Form Calculation widget. It adds tomato and potatoes.

    How to perform advance calculation and validation on matrix field? Image 2 Screenshot 51

    d. We want that total to be ('no. of family members' x 500). If that's not the case, the form shouldn't submit.

    You can do this adding another calculation widget in order to calculate (no. of family members* 500). As you have already set the no. of family members required, the form will not be submitted if the user does not enter any value in that field. 

    How to perform advance calculation and validation on matrix field? Image 3 Screenshot 62

    As I have seen your form and calculations seem to work. 

    All in all, If you see any logical issue belongs to conditions, please check the documents that my colleague Charlie has already forwarded to you in the previous threads.

    I hope this helps.

    Thanks.