Enable question or section, based on response to earlier rostered multi-select response

Hi, I have a multi-select question “s4_2” within a member-roster “r4”, and the 1st answer option inside the multi-select “s4_2” is “Crop production”. I have another unrostered question (or another section, say “s8”) later on, which I want to activate only if there is any case in roster “r4” where the 1st option “Crop production” is selected. So suppose there are 3 members within roster “r4”, and two of the members in “r4” selected the 1st option in the multi-select “s4_2” (Crop production). I want the unrostered question/section “s8” to activate then.

I tried multiple codes including: r4.Any(x=>x.s4_2.Contains(1)), but that didn’t work. I think it’s because the “1” within brackets in “.Contains” looks for the rowcode 1?


The expression


looks good. It literally means “Any member has mentioned crop production in his/her employment answer to question s4_2”.

Rowcode is a roster thing. The Contains() function can be used without a roster and has nothing to do with it or with the rowcode, unless you mention it specifically:

1 Like

Hi @sergiy ,
Thanks, yes it was supposed to work, but it’s not working in either of the 2 places I’ve used it. I’ll try to elaborate here along with screenshots, in case you can help further :slight_smile:

In my Section 1, my variable s1_1 is a List question that lists all household members. Following that question, the Roster r1 is the household roster that draws from the list in s1_1.

Then my Section 4 deals with Wage Employment in Agriculture. At the very beginning of this Section 4, I ask a multi-select question s4_1, which asks to select all the HH members aged 15 and above. This multi-select question (s4_1) is bound to the roster r1.
Following the multi-select s4_1, is my roster r4, which shows only the household members selected in the preceding multi-select s4_1. However, instead of being bound to s4_1, the roster r4 is bound to the initial list question s1_1 (the very first question in Section 1), with an enabling condition: s4_1.Count(x => x[0]==@rowcode) > 0.
The following question inside roster r4 is s4_2, which is a multi-select fixed (reusable) list of items, which includes “Crop production” as the first option.

The problem somewhere in these codes, is that when I next try to activate/enable a section based on a selection made in s4_2, [e.g. r4.Any(x=>x.s4_2.Contains(1))], the section is only enabled when the mentioned selection is made for the 1st household member in the list, not for any other.
So, suppose my Household has 3 listed members in this order: “Father”, “Mother”, “Daughter”, then the subsequent section will only activate when I select “Crop Production” in s4_2 for “Father”, not for any other members.
Similar problem is arising in another section (Section 7), where I’ve used the same format, hierarchy, and coding as in Section 4. I’m attaching screenshots below:

Hello @adiberg ,

thank you for the screenshots. I think I can recommend changing Contains(1) to ContainsAny(1) in this case. The difference is subtle and rather technical, but you can read more here:

I attach a minimal example below in PDF:
4081.pdf (176.4 KB)

Hope this helps.
Best regards, Sergiy

1 Like

Dear @sergiy , thank you so much! This works perfectly! :slight_smile:


Thank you for confirming, and best of luck with your survey!

1 Like