Not showing error even if % is not adding to 100

Hi, I want the survey to not proceed further if calculation doesn't add up to 100%.

I think i am making some mistake, however, not able to identify it.

Could someone please suggest the error i am making in the attached file?
Calculation_Error.xlsx (20.6 KB)

You have your sum check, ${Q14_a_} > 100 or ${Q14_a_} < 100, in the required column, which is used to indicate whether a question must be answered or not. You should probably move it to the relevant column - to display your error message note when the sum is not 100, or alternatively use it as a constraint and use constraint_message to display the error. See https://docs.getodk.org/form-logic/#validating-and-restricting-responses for details.

Also, you can simplify your check a bit by just having: ${Q14_a_} != 100 ; the "!=" means 'not equal'

1 Like

Thank you Xiphware for your suggestions, unfortunately, it's still not working.

However, I noticed on removing "relevant" from the question number Q14_a_2, Q14_a_3, ...........Q14_a_8, it starts working fine with the same logic.

Any other suggestion do you have?

Calculation_Error.xlsx (20.6 KB)

Hi @nalinsharma2004,
Try this:
You still need to delete what you have in the "required" column.

The required column is just a TRUE/FALSE column, it should not have any formulas in it.

Hope that helps,
Janna

@nalinsharma2004,

Looks like you have not inserted the constraint condition (what validates if the sum is 100). In the constraint column of Q14_a_note, insert ". ${Q14} != 100" In the constraint_message column, add an error message to be displayed to the enumerator/staff when the sum is less than or higher than 100.

Paul

(unrelated to issue at hand, but as bit of an aside, yes you can actually put an arbitrary XPath expression in a required condition, although it is almost always just static true or false. eg "If you answered 0 for question ${Q1}, then question ${Q2} is now mandatory and not optional" would be represented as Q2 required: ${Q1} = 0