Issues with constraint

Hello all,

I have a difficulty in enforcing constraints and i need your help.

I have three questions sex, age and relation_to_head.
sex with select one Male(1) and Female(2).
age with and integer value.
relation_to_head with select one option House head/Husband(1), House head/Wife(2), Child(3), Relative(4), Brother(5), Sister(6) and Maid(7).

I want to put the constraint on the relation_to_head question. what i want is
if sex=1 and age>12 then relation_to_head only options 1 or 3 or 4 or 5 or 7 are allowed.
if sex=2 and age>12 then relation_to_head only options 2 or 3 or 4 or 6 or 7 are allowed.

I need your help with this

I tried this constraint but it works only when age>12 only

((${sex}!=β€˜1’ or ${age}<=12) or (.=β€˜1’ or .=β€˜3’ or .=β€˜4’ or .=β€˜5’ or .=β€˜7’)) and not(${sex}=β€˜1’ and ${age}>12 and (.=β€˜2’ or .=β€˜6’))

here is my form
ttt.xlsx (10.7 KB)

Looking forward to your support as usual.

Thanks,

@alazar_baharu, is it that the age should be greater than 12 for both cases? One more query can one select choice 3 or 4 in either case?

yes the age should be >12 in both cases and the question is select_one.

@alazar_baharu, do you mean all the respondents’ age should be >12 years?

No. I just want to restrict options based on sex and age.

to be a house head/husband age should be >12 and sex=M
to be a house head/wife age should be >12 and sex=F
and to be brother sex should be M, to be a sister sex should be F.

@alazar_baharu, maybe you could do it as outlined in the image shared below:

In the survey tab of your XLSForm:

Image 1

In the choices tab of your XLSForm:

Image 2

Data entry screen as seen in Enketo:

Data entry screen as seen in Enketo:

Data entry screen as seen in Enketo:

Reference XLSForm:

ttt.xlsx (11.3 KB)

Dear @Kal_Lam thanks for the support. your remedies are working well for me.

1 Like

@alazar_baharu, :clap: :heart: :partying_face: