Returning a list of multiple select questions which doesn't contain a previously selected choice

What is the problem? Please be detailed.
I have a list of choices. first question asks about the main item and is a select_one scenario.
the second question is to select other minor items from the same list and is a select_multiple scenario. I would like to have it designed such that after selecting the main item, it is not given as an option in the list for the second question.
E.g list of choices is A,B,C,D,E,F
if at question 1 the selected item is A, i would like the available choices in the next question to be B,C,D,E,F only.

What steps can we take to reproduce the problem?
So far, all the solutions i have found deal with returning the selected choice only.

What ODK tool and version are you using? And on what device and operating system version?
I am using excel to design the form.

Hello Green,

It's possible to achieve this. you will need to use filters as indicated below:

  • Involved columns are "choice-filter" in survey and "filter" in choices.

Step one: Define the choices (name and label) in the choices and then add an extra column called "filter" of which the content is the copy paste of the "name" column.

Step two: create your variables (select_one and select_multiple) as desired

Step three: add the column "choice_filter" and pass the following function for the select_multiple question
not(selected(${VAR1}, filter)) which in other words returns all items that were not selected previously

See this this form for quick reference

Cheers.
Jules R

2 Likes

Great tip, @jules_rugwiro. I don't believe the filter column is necessary. A simpler choice_filter condition given that var1 is the first name of the first select would be name != ${var1}. This may make it a little more clear that all we're doing is including all the values that didn't get selected in that first select.

3 Likes

A post was split to a new topic: How can I remove selected select choices after each repeat?

Thanks a lot guys. Problem solved. I only had to use the choice_filter.

1 Like

Glad you got it working, @Immie_Green!

@jules_rugwiro asked me a really good question in private message and I hope he won't mind that I answer here because I'm sure others have it too. The question is what exactly name represents in the name != ${var1} expression. It is indeed strange because it's one of the only places in an XLSForm where you would see an identifier without quotes or ${} around it.

In a choice filter, an identifier without quotes or ${} around it refers to a column in the choices sheet. In this case, it refers to the name column used to identify the underlying value of the choice. What the choice filter does is consider all of the choices in the list and try the condition to decide whether to keep it or not. So in this case, it would look at the name and if it's not equal to ${var1}, it would keep it. But if a name does match ${var1}, that choice is excluded ("filtered").

@jules_rugwiro, what you did gives the same result, it's just a little more complicated. Instead of doing a test against the name column directly, you introduced a new filter column and tested against that. It's not a problem, I just think it makes it a little less clear that ultimately you want to compare against the name.

You also used not(selected whereas I used !=. Your way works as well and would be necessary in the case of a select_multiple. I find testing for equality is simpler if we know ${var1} is the result of a select_one.

Hope that answers your question @jules_rugwiro and gives you a little more insight into how things work!

2 Likes

Hello @LN
Thanks a lot for the clarifications. Your approach saved me more that hours today. I was creating a form that had quite a number of filters I wouldn't have managed relying only on my old school method.

On a different note, do you have any automated way/tool that you use to generate SPSS Data dictionary straight from the XLSForm? I am making one and almost to the deployment phase but would like to hear from experts

Cheers,
JR

I'm so glad the explanation was helpful, @jules_rugwiro! And that was thanks to your initial helpful response -- sometimes answering questions is the best way to learn.

I don't but I also don't use SPSS so I'm not the best person to answer that. I bet that if you open a new support topic you'll get interesting suggestions or perhaps others who would like to collaborate with you.

Hi. I tried this but it only works if you select one option. It doesn't work for multiple select questions for me. Any clue why?

When you have a multiple select, the answer can contain multiple options so you don't want to compare it using =. Instead, use the selected function. The filter would look something like not(selected(${var1}, name)).

This is what @jules_rugwiro had originally suggested. I tend to use =/!= when using select ones but selected works with both select ones and select multiples.

2 Likes

4 posts were split to a new topic: Problems with using pulldata function