I’m working on building a form and I have 4 input fields that take in numbers. These input fields appear on a conditional basis based on the multiple options selected in a previous question. That is, if some values are selected in the previous question, only 2 input fields are displayed, etc. I want to validate the sum of these input fields to be exactly 100. The sum should not be more or less than 100. If it is, I want to show an error message. How can I do this? Please help!!!
Hi @Kal_Lam - That’s fine. It’s a secondary issue that we can discuss later. But before that, I wanted to know how I can also validate the sum to be exactly 100? With the solution you provided here, I am able to validate/show errors if the sum exceeds 100. But how can I show errors if the sum is less than 100?
Please let me know! Thanks a lot!
This is all about the logic of your check; When you need a check that assesses for a condition that is less than 100 as opposed to excess than 100, you need to reverse the calculation from the discussion.
Hi @stephanealoo - Thanks for your response. Yes, I understand. Would this work for BOTH the constraints? I mean the constraint to check if the sum has exceeded or is less than 100? In my form I need to strictly force all the values entered to be a sum of 100 and nothing else.
Here, based on the checkboxes that the user selects, they will have to provide the integer value for each of the regions. For these integer values, I need to force the user to always add integers that sum to a 100 (nothing more or less). Based on the logic I have in the xls form, I am able to validate for values whose sum exceeds 100. (See screenshot below)
But if I have values that sum up to LESS than 100, it does not show an error. I’m unable to figure out the logic here because using .>=100 allows the user to put in values greater than 100, and it does’y satisfy the condition I am looking for.
It took me a while to think this through because you are having your integers based on a multiple selection. So you needed to introduce coalesce function in calculate questions after each of your integer. In summary, try this form and work from it to have your final work. kobo-form_SA.xlsx (17.1 KB)