Filter a list of individual options depending on different regional choices (@optioncode, Inlist)

I am designing a questionnaire in which the list of options for single and some multi-select questions changes depending on three different regions (1-3). I would like to filter the options accordingly. I need to pick the options by their numbercode in the filter field. For a range of numbers I got this working:

a2province==3 && @optioncode<=3 ||
a2province==1 && @optioncode>=5

However, I seem to be unable to pick a subsection of individual number-codes from the overall options since I do not know how to combine @optioncode with the InList() function (if that is the best function to use):

a2province==1 && @optioncode.InList(1,2,3,4,5)

Any advice is greatly appreciated.

jk

Jan,

you could use, for example:
((int?)@optioncode).InList(1,2,3,4,5)
or
new[]{1,2,3,4,5}.Contains(@optioncode)

Both having identical effect.

Best,
Sergiy Radyakin

I don’t understand your question. What is a “roster list of items”? Is this Survey Solutions LIST type question? Is this a roster? Is this a linked question to a question in the roster? What do you want to filter there?

What does it mean “filtering the items list for which the questions are asked for different provinces?”

Please use Survey Solutions terminology. I can only hypothesize that “cascading selection”:http://support.mysurvey.solutions/customer/en/portal/articles/2470037 may be useful here.

Best, Sergiy

Sergiy,

thank you for this, it works perfectly for the simple lists. Is there any way I can use a similar approach to questions referring to a roster list of items, i.e. filtering the items list for which the questions are asked for different provinces? I tried current but am getting the syntax wrong it seems.

Dear J.

You can put an enabling condition on the whole roster and this condition should utilize the earlier asked province and the @rowcode system variable, which will allow you to distinguish between the various items. For example:

((int)Math.Floor(@rowcode/100) == provcode) || (@rowcode<100)

Items that are filtered out may be hidden away with the corresponding flag “hide if disabled”.

Best, Sergiy

I am trying. With items I am referring to the items listed in the roster - i.e. the list of items for which questions are then asked. This list of items I would like to filter depending on a choice of a province in an earlier question.
In other words I would like to filter the roster items for each province in a specific way. If this is possible.
The task would be the same as with the initial question referring to filtering a single selection list of items.

Best
j

Jan,

a condition on a roster never expands the number of rosters. A condition on a roster may only reduce the number of items in a roster.

Given the description provided so far “…filter the roster items for each province in a specific way.” the advice given in my reply from July 19 is the best strategy delivering the desired behavior.

Sincerely, Sergiy

Dear Sergiy,
we did not yet manage to design the filter we need for the rosters. We would

–> either need to filter a fixed set of items within the roster depending on the province chosen in an earlier question;

–> or connect the roster to a list of items that is not part of another question but a list of items that can be filtered depending on the province choice (so is not filled in by the enumerator - it should not be a multi-select question, - or it should be a multi select question where all filtered options are automatically selected)

We tried the combo-box option but this works only for single select questions and we cannot tie the roster to a sigle select question.

In your response of July 19th you suggest putting an enabling condition on the whole roster (one roster for each set of items for each of the provinces). This is what we did thus far but that expands the number of rosters greatly (three for each questions where some of the items asked for are province-specific). This is why we want to integrate those three rosters into one using a filter option.

Dear Sergiy,
thank you for trying to understand the problem - but I seem to be pretty poor at explaining the issue.

Right now we have a choice between three provinces in the questionnaire (1,2,3). The list of local institutions we are interested in and are asking questions about (in rosters or in simple single and multiple choice questions) are slightly different for each province. 70% overlap, 30% are different.

We could have designed three questionnaires, one for each province (and I think we should have done this but it is too late now).

But we tried to solve this by filtering the answer options for each province from a master list of all options across the three provinces.

For normal multiple or single choice questions outside rosters your code above helped us to do this via a filter option
e.g. province==2 && ((int?)optioncode).InList(1,3,4,8) || province==3 && ((int?)optioncode).InList(1,2,3,4,5)…

For the rosters this filtering does not work. So we are stuck with creating three rosters, one for each province, with enabling conditions that hide the two rosters not connected to the chosen province.
On the tablet this works fine - but for later data processing (reshaping and merging the rosters into the main STATA database) this is a bit of a nightmare. So one roster per question filtered for the actual province would be better than three rosters per question with enabling condition.

That is about it. But if it requires serious programming and not a simple code I will be unable to accomplish this in the remaining time window and will leave this to the next survey to investigate.

What does in mean: “For the rosters this filtering does not work” ?

  • For the roster source (fixed set of items) there is not filter option, right?
  • For the roster source (multi select question) I could use the filter on the multi select question but I do not want the enumerators to select all options shown for the list filtered according to province - and there does not seem to be an option to pre-select all.
  • For the roster source (list question) - well, I do not want the enumerator to punch in a list
  • Cascading combo box only works for single select and that is not option.

Sergiy, I have the feeling that I am not coming across. Let us leave it at this. Unfortunately, I am a social scientist, not an IT specialist.

Jan,

I might be interpreting your last statement as disappointment with us. You should not be. We are trying to help our users. The problem is that we are now working with users from 100 countries and our resources are stretched. We do ask our users to make an effort and explain your problem with as much details as possible. Prepare examples, make screenshots, videos that would help us to help you. Statements like “X does not work” are not informative at all regardless whether you a social scientist or an IT specialist. BTW, Sergiy holds a Ph.D in economics from University of Hanover, Germany.

I also got a feeling, by reading your questions, that you take a paper questionnaire as given and try to fit it exactly as it is to Survey Solutions. I think it is a wrong approach. CAPI systems are inherently different from paper. So, instead of trying to square the circle, and write complicated algorithms, it might be more productive to modify your paper questionnaire in such a way so it can be easily programmed in CAPI.

If you have time, would you please provide your objective feedback on Survey Solutions for the software evaluation site: http://www.capterra.com/p/153927/Survey-Solutions/

Thanks much,

Misha

Jan, in your last email you are wrote: "- For the roster source (fixed set of items) there is not filter option, right? "
I think this explains the confusion. Yes, you can filter items in the fixed roster as well!!

The confusion is (I am guessing) that you attempt to filter the source (roster trigger question) while in fact you should filter the consumer (the roster itself). With that in mind you refer to @rowcode in the roster’s ENABLING condition, which enables/disables the items of the roster and in combination with the hiding flag functions exactly like a filter for items in the roster.

@rowcode will be the value of the fixed item code in the fixed roster, item code from the MCQ for MCQ-triggered roster, item index for numeric roster, and a list-triggered roster. (in the latter case with possible gaps in numbering due to deleting the items from the list).

So you are one step away from the solution, but you divert yourself with the wrong strategy.

Stratified questionnaires are quite popular these days, where the sets of questions differ e.g. for treated and controls, or for first visit and revisit, etc. And of course Survey Solutions provides a full set of tools for these scenarios.

Hope this helps.

Best, Sergiy Radyakin

Hi Sergy
I’ve got a questionnarie which has the following question (multiple choice) “select the type of fuel”, where I have to select the kind of fuel of my preference. Within the options I can choose for example “gasoline” or “glp”, However, when I select two types of fuel at the same time in the first question, I am supposed to have two different sort of measuremensts as a result, but instead, the same units of measure appear, which is wrong, it is here where I’ve got the issue. I’d like your help with this .

In addition to this, I attach you the screenshot and code I am using

(v_prg32_sec8.Contains(1) && @optioncode.InList(1,2)) || (v_prg32_sec8.Contains(3) && @optioncode.InList(1))

Hi Sergyi, anynews about my question please, i have several questions with this problem

Thanks

Since your question for Unidad de Medida is in a roster, your syntax for filtering option should filter the options based on the rowcode and not the multiselect question like your current code.

Try this syntax instead:
(@rowcode==1 && @optioncode.InList(1,2)) || (@rowcode==3 && @optioncode.InList(1))