Select Multiple and Relevance

What is the problem? Please be detailed.
Hello ODK Forum Members,
I have 2 similar, but separate issues. I am using xls form with Kobotoolbox and need the questionnaire only be displayed online (using Kobo's instance of Enketo).

Problem 1
select_multiple question A. The question has 10 answer options, and for 3 of them the same follow-up question is asked. Under relevant, I have succeeded with "or" to say ${actor} = 'tun_trader' or ... to make it work. And as long as only one of the three relevant options is chosen, all works fine. But if two or all three are chosen, the follow-up question is not displayed in the web-form (I have not tried in the app, as I need it to work in the web-form).

I have tried to think of all solutions and add more "or" options where the two/three options are combined with "and", but it does not work.

Problem 2
Different select_multiple question, again more than 10 options. For two of the options are follow-up questions. But two different ones this time. While all works well with using relevance. This only works if only one of the options is chosen. I would like (read need) it to display both follow-up questions to be displayed, if the two relevant choices in select_multiple question are chosen.

Thank you very much in advance!

1 Like

Hi @arqaam,

Did you use brackets in the relevant column like the expression: (${actor} = ‘tun_trader’) or (${actor} = ‘SecondPossibility’) or (${actor} = ‘ThirdPossibility’)?

2 Likes

Hello,
the problem is not with the "or" part, its when I select more than one option in the "select_multiple" question.

Hi @arqaam,

Have you tried using the function selected(${variable},'option')?

It would be something like this: selected(${actor},'option1') or selected(${actor},'option2') or selected(${actor},'option3')

Hi,
yes I have tried it. And it works well, as long as only one of the respective options is chosen, the problem appears when more than one option is chosen, then the follow-up won't appear.

Hi @arqaam,

The problem is that ${actor} contains more than 1 answer if the user select 2 or more answers. If the relevant contains or, this cause a problem because he has chosen and (several answers).
You can try in the relevant column to eliminate the other choices with the expression:

not selected(${actor}, NotDesiredChoice1) and not selected(${actor}, NotDesiredChoice2) and ....

Eliminate all choices except the 3 that are relevant.

Good luck.

1 Like

Hi,
this did not work. Also with
not(selected(${actor}, 'NotDesiredChoice1'))

I think the problem is with the "select_multiple" and actually choosing multiple. I found a workaround with a ranking and select_one.

Thank you for your suggestion nonetheless!

selected(${actor}, 'choice1') or selected(${actor}, 'choice2') should work. Please post a form isolating just that question and the question that should be relevant or not.

2 Likes

Problem 1: see Helene's answer.

Problem 2: "...if the two relevant choices in select_multiple question are chosen" then both the dependent followup questions (or a group around them both) need relevant = selected(${actor}, 'choice1') and selected(${actor}, 'choice2') . Note, you didnt say "... if and only if the two relevant choices...", which would require a more comprehensive test to explicitly ensure nothing else was selected.

1 Like

Hi Helene,
I had not read properly, and your solution works for both problems! I apologies for the confusion. I had read on xlsform, that you now can use ${likes_pizza} = ‘yes’, but failed to read that it's only used for select_one options, or if you do not want to allow others!

Thank you very much for your answer and solution. Highly appreciated!

1 Like

Hi @LN,

Doesn't it come to the same as

that I have offered as a solution inhttps://forum.getodk.org/t/select-multiple-and-relevance/10156?

Hello,
I read on xlsform about it. Your option only works with select_one or if you only ant one answer option of a select_multiple question. As soon as you want others options to be selected, while you have a relevance on your chosen option, you need to write the relevant, in the way Helene did it.

1 Like

Glad it's working, @arqaam!

@Souirji_Abdelghani I think your solution would be perfect for a select_one or when only one option is selected but not when multiple options are selected. For example, the value of actor could be 'tun_trader SecondPossibility ThirdPossibility' if all three are selected or 'tun_trader foo bar' if 'tun_trader' and two unrelated options are selected. In those cases, all three of your checks would fail but the intent is that the whole statement be true if any of the possibilities are selected.

1 Like

Hi @LN and @arqaam,

You're both right. I indeed have overlooked that fact; sorry for that.

Thanks a lot.

Hello ODK forum members,
I have an issue.
I have a multiple select question with choices, e.g., A:F, and when you select 2 of the choices, e.g., C and/or D, I want the succeeding question to show. How do I go about it?

See the count-selected() function. Specifically, probably something like this on your succeeding question should do the trick:

relevant: 'count-selected(${q1}) = 2'

I have six choices for a question, and you can choose more than two, two of which are of interest. I want the subsequent question to appear after you have selected one or two choices of interest, with or without the other choices.

If there are specific responses that are of interest - in your case, apparantly only 2 (C & D) - and you don't really care about any additional selections, then I'd probably suggest using a selected() relevant expression, instead of the option-agnostic count-selected(). eg

relevant: 'selected(${q1}, "C") or selected(${q1}, "D")'

Have a play around with this:

choices.xls (19.5 KB)

1 Like

The above command did not work in my case. I needed a command when the two choices of interest are both selected and/or when either of the choices is selected.

Can you please post the form you are attempting; the above or logic should be what you desire; namely, the following question is shown (ie relevant) when "user-selected-C or user-selected-D" (either or both) is true.

1 Like