Constraint for Select One question

I have a Select many question (What are your sources of income?) followed by a Select One question (which one is the main source of income?).
How can I use Validation Criteria in the Select One question to ensure that respondents can only choose one of the options selected in the first question?
Can you help?

Welcome to the community, @michaelkunnuji! Could you share a dummy question and choices for this so that the community can also help you? Also, be sure to share the condition that you expect.

Many thanks, Kal_Lam.
Question 1 - Select many: What are your sources of income?
Question 2 - Select One: Which one is the main/most important source of income?
See image attached.
I need to ensure that for Question 2, only those who chose a particular option in Question 1 can choose that option as their main/most important source of income.

Thanks a lot.

Go to the setting option of Question 2 >> Then Skip logic>> Then add more that one logic as you said, Q 2 should be opened only for some specific replies of Q1… There will be option to choose

  1. “Questions should match all of the these criteria”
  2. "Questions should match any of the these criteria "

take 2 and save the form.

Thanks @rahul_521, but the Skip Logic does not solve the problem. I want all the respondents to answer Question 2. However, I want anyone choosing ‘Return on Investment’ to have selected this option (and maybe other options) in Question 1. I need a Validation Code that will reject someone who chooses Salary as the main source of income if they did not choose that option - Salary - in Question 1 and that applies to all the other options. Is my challenge clearer now?

I tried to write the Validation Code this way: not(${_1_What_are_your_sources_of_in} != ‘1’ and . = 1) and (${_1_What_are_your_sources_of_in} != ‘2’ and . = 2) and (${_1_What_are_your_sources_of_in} != ‘3’ and . = 3) and (${_1_What_are_your_sources_of_in} != ‘4’ and . = 4) and (${_1_What_are_your_sources_of_in} != ‘5’ and . = 5) and (${_1_What_are_your_sources_of_in} != ‘6’ and . = 6)

Please, what is the problem with the code? I keep getting this error message when I try to proceed to the form:
There has been a problem trying to replace ${_1_What_are_your_sources_of_in} with the XPath to the survey element named ‘_1_What_are_your_sources_of_in’. There is no survey element with this name.
I need help with this. Thanks.

This is the Validation code I used: not(${incomesource} != ‘1’ and . = 1) and (${incomesource} != ‘2’ and . = 2) and (${incomesource} != ‘3’ and . = 3) and (${incomesource} != ‘4’ and . = 4) and (${incomesource} != ‘5’ and . = 5) and (${incomesource} != ‘6’ and . = 6)

This is what I am getting.

@michaelkunnuji, you should 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:

Reference XLSForm:

choice_filter.xlsx (64.1 KB)

This is super-helpful @rahul_521. Really grateful. Stay blessed.

1 Like