I am failing to put a constraint that will stop capturing if the household has zero occupancy. Can someone help? I have the following variables
Under2s,
Y2to5Yrs,
Y5to18Yrs,
Y18to60Yrs and
Over60s
How can I ensure that the app doesn’t continue if the total is 0 or less
I tried this where the sum of all those variables must be greater than zero like this
(${Under2s} +${Y2to5Yrs} + ${Y5to18Yrs} + ${Y18to60Yrs} + ${Over60s}) >0
Hello @bkgwadi,
What is the error you get?
Maybe you need to work with coalesce().
See https://docs.getodk.org/form-operators-functions/#coalesce
Or set a 0 default for all ages.
Side-note: Maybe clear ages naming: Borders of 5 and 18? ${Y2to5Yrs} + ${Y5to18Yrs}
5 years old (birthday): Is this in first or 2nd group?
I get no error as such. My constraint statement is not preventing (controlling) as my aim. Those are the age categories that I need in my tool according to some indicator. Y5to18Yrs will be for “Number of 5 to 18 year olds in the household”. So I want to prevent a GIGO effect whereby a user can input zeros and the app should control against household occupancy. Anyone to help in constituting that control statement?
Hi @bkgwadi
You need to use a step-by-step approach to validate each entry progressively. Could you confirm the following:
- What is your intended data collection approach?
- Are these questions appearing in a group with an appearance setting field-list?
Regards,
Stephane
Hie. I want to check if there is a household with zero membership on the last variable and if so, error message with an aim to re-enter anew the 5 variables again just in case the capturer might have missed it.
These are not in a group, I can put them in a group but I will still be stuck with failure to control the above situation.
So, ${Y2to5Yrs} is 2 years (from birthday on) up to LESS than 5 years?
And ${Y5to18Yrs} is 5 and more up to LESS than 18 years?
If a person is 5 years old do I count her/him in ${Y2to5Yrs} OR in ${Y5to18Yrs} ??
Hello,
Would you mind to provide the related part of your form to the community to allow better support?
HouseholdOccupancy.xlsx (24.2 KB)
Check my constraint on row 18. I am trying to check if total household occupancy is zero, if so then we re-capture from row 14.
@bkgwadi, maybe this is something what you were looking for.
In the survey tab of your xlsform:
Data entry screen as seen in Enekto: when the sum is >0
Data entry screen as seen in Enekto: when the sum is equal to 0
Reference xlsform:
Household Occupancy.xlsx (12.8 KB)