Constraint on Response

Hi everyone, I am trying to set a constraint on two responses of a second question following the first.

Q1 asks: Is the beneficiary who this survey relates to a male or female? Q1 has two possible responses: male or female.

The second question asks: Who is the survey being applied to? Q2 has two possible responses: Beneficiary or Beneficiary Family Member.

The constraint is for Q2: if the survey relates to a male beneficiary, the respondent must be a beneficiary’s family member. If the survey relates to female beneficiary, the respondent must be the beneficiary themselves. I am trying to constrain the answers such that “Beneficiary” response for Q2 can only be selected if “female” was the response for Q1 and “Beneficiary family member” response for Q2 can only be selected if “male” was the response for Q1. Is there a way to do this?

@cmarin ,

Your explanations seems not clear, if you can share part or section of the questionnaire, it will be fine for proper explanation

@cmarin, maybe you should also be able to do it as outlined in the image shared below:

In the survey tab of your XLSForm:

In the choices tab of your XLSForm:

Image 2

Data entry screen as seen in Enketo:

when a wrong entry is made:

when a correct entry is made:

when a wrong entry is made:

when a correct entry is made:

Reference XLSForm:

constraint.xlsx (13.1 KB)

1 Like

Thank you for the response and apologies for the delayed response. The Excel format does not work for me.

I receive an error message either way in Kobo

Hi @cmarin,

Can you also share a screenshot of the choices tab of the relevant questions?

There might be a chance that you are using labels instead of names

1 Like

Screen Shot 2022-08-15 at 1.25.26 PM

Hi @cmarin,

Can you try this one:

(${gender}=male and .=beneficiary) or (${gender}=female and .=beneficiary_family_member)

1 Like

Thank you for the quick response. It does not pull up any constraint
Screen Shot 2022-08-15 at 1.38.15 PM

Is there a way to set this up as two separate conditional questions? For example:
Q1. What is the gender of the beneficiary?
Q2. (Relevant: if male) who is the survey being applied to? With a constraint then if the enumerator selects “beneficiary”?

@cmarin, one last time, can you also show the type of your questions tab?

1 Like

Hi @cmarin,

The constraint in your screenshot is different.

1 Like

Just so that you know - the image you showed matches the constraint well, so there should be no error message shown. Kobo is working as expected.

If you want an error message shown when ‘male’ and ‘beneficiary’ are both selected - your constraint needs to be the other way around, like:
(${gender}=male and .=beneficiary_family_member) or (${gender}=female and .=beneficiary)

1 Like