How to contraint an answer to a question so that it doesn't exceed the sum of two answers in previous questions

If I have the following questions:

  1. How many people live in the household?
  2. How many of them are female?
  3. How many of them are male?

How do I put a constraint to make sure that sum of the answers given for 2 & 3 (females and males) don't exceed the answer to 1 (total number of people)?

Thank you!

1 Like

My suggestion would be to re-order the questions such that question 1 becomes the last. Check my attached xlsform.
Demo.xlsx (11.0 KB)
Perhaps you can rephrase the questions so that they have a natural flow.

Thank you Arqaam! That's helpful.

Acá dejo otra solución
Demo1.xlsx (11.2 KB)


Muchas gracias! This looks great. I understand what the contraint does, but could you explain the 1 and 0 in --> if((. + ${f}) = ${p}, 1, 0)
Would it be possible to explain this in words? So that I can do it for other cases as well.

Thank you very much again!

Estamos para ayudar. El significado es el siguiente:
1 = true
0 = false