Show error around the inputs whose sum is more or less than 100

Hi all!

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!!!

CC: @Kal_Lam

@saumyaupadhyay, maybe this post discussed previously should help you solve your issue:

Thanks for your response @Kal_Lam. I will try it out. Also, I wanted to check if there is an ability to add input fields in the form with labels inline?
For example:

  1. First label: ** Input field **
  2. Second label: ** Input field **

Please let me know! Thanks!

Sorry, could not get you clearly on this:

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!

Hi @saumyaupadhyay
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.

Change each using the following logic
.>=100 and .>=(100

You can continue with this logic to create the rest of your form.


1 Like

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.

Hi @saumyaupadhyay
Can you start developing the logic based on what we have provided and let us help you if you have a problem? Send us the XLS you have developed.


1 Like

Hi @stephanealoo - I tried to change the logic but that doesn’t seem to work. Here’s my xls form:
kobo-form.xlsx (13.8 KB)

The validation constraint that I’m trying to add is for this question:

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.

Please help!!

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)


1 Like