Get Difference of two numbers inside a repeat group

Hi Vipin,

If you would like this value to be computed for you, you can use a Hidden
to represent the difference (instead of an input question), and then
setting the expression you have to take the difference as the
Calculate expression
for that hidden value.

If you want to display the result to the user, you can create a Label and
drag the new hidden value into its display message to the user.


··· On Mon, Jun 5, 2017 at 5:18 AM, Vipin Gupta wrote:


In my form, I have repeat group and inside that repeat group, I have two
numbers - planned and actual and in third number field I need a difference
of those two numbers.

Enclosed is the screenshot of my form.

When I try to get difference it is giving me a warning and also it is not
calculating the difference in the form.

Please advise.

Vipin Gupta

You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to
For more options, visit

Hello @Clayton_Sims, @Mazz

How can i restrict a user from proceeding to another question if the addition of two questions using a hidden field does not equal 100?

The most common pattern to follow for validation conditions which depend on the answers to multiple questions is to create a Label question with the Validation Condition false() whose display condition only makes it visible when the answers to the previous questions are invalid.

This allows you to pop up a message to explain the invalid input to the user, and block them from proceeding. Note: I believe the “block the user from proceeding” component of this solution currently doesn’t work in Live Preview or Web Apps, but does work on the Android client, so you’ll need to test that part on the phone directly.

Thanks but it still doesn’t prevent the user from answering other questions. This is how i set it up

I intentionally entered figures that didn’t add up to 100 but it didn’t prevent me from moving further into the survey, the only thing it did was not to display the label. How can i correct this please?

Your check expression looks backwards to me, it should test for whether the condition is violated, rather than whether it passed.

Hello @Clayton_Sims,

Still struggling with this please

This still permits the user to proceed even when the hidden calculation doesn’t add up to 100.

try taking the single quotes out and just type the 100