Select multiple with 'relevant' expression

Hi All,

I am trying to create a 'multiple' selection question where the follow on for each selection clicked presents a further question in this case a percentage option. In the 'relevant' column I have this expression:

${vegetation} = ’sphagnum’ (which works for a single selection).

Can I add several more options to the same expression? If so is there an example available or do I have to have each ground cover as a new question so it will cascade onto the percentage question.

Could I for example:-

${vegetation} = ’sphagnum’,'heather','rush' etc?

Hi @Paul_Shapley
you can combine your expressions using and/or if this is what you need.
Here is a sample Multiple constraints using AND and OR

Hi Grzesiek2010,

Thank you for answering so quickly. Just not sure how to structure that.

Do you mean like:-

${vegetation} = ’sphagnum’OR'heather',
OR'rush'

or

$({vegetation} = ’sphagnum’AND'heather',
AND'rush')

It depends what you want to achieve. If you want to do something when at least one option from those you listed is selected then you should use or otherwise if you need all of them you need to use and.

Another thing is that if you use select_one question then you can do that like in your sample:
${vegetation} = ’sphagnum’
but if you use select_multiple your expression should be:
selected(${vegetation}, 'sphagnum')

The last thing is that if you combine multiple elements with or/and it should be:
select_one: ${vegetation} = ’sphagnum or ${vegetation} = ’heather’
select multiple: selected(${vegetation}, 'sphagnum') or selected(${vegetation}, 'heather')
not like in your sample (you need to repeat your question name every time).

Hi Grzesiek2010,

I changed the expression to:

selected(${vegetation}, ‘sphagnum’) or selected(${vegetation}, ‘heather’) or selected(${vegetation}, ‘grass_not_molinia’) or selected(${vegetation}, ‘molinia’) or selected(${vegetation}, ‘sedges’) or selected(${vegetation}, ‘rush’) or selected(${vegetation}, ‘cotton_grass’) or selected(${vegetation}, ‘trees’) or selected(${vegetation}, ‘bare_ground’)

However this add each selected ground cover into the same percentage group.

I want (if it is possible) to add a separate percentage for each selected ground cover.

Many thanks for your help.

Paul S

Hmm I think like I focused to much on the expression itself and missed what you rally want to achieve...
Do you want that percentage question to appear for every single selected item in question one? (three times in the case from your screenshot)?

Hi Grzesiek,

Yes...that's right if I select 5 options a pecentage choice for each one would appear in order they were selected.

Paul S

So you need something completly else. After your select_multiple question you need to crate a repeat_group with repeat_count = count-selected(${name_of_your_first_question})
inside that group you can add the question you want to be repeated and it will be repeated accordingle to the number of selected items in question one.

You can find similar topic on the forum:

Hi Grzesiek2010

Your first suggestion seems to be what I want. How do you 'end' a 'repeat_group'?

repeat_group

end_group??

Cannot find any reference to 'repeat_group' anywhere.

Thanks,

Paul S

end_repeat you should find more in the documentation: https://docs.getodk.org/form-repeats/

Hi Grzesiek2010,

I am getting the following errors:

I does not seem to like two 'end_repeats' not sure why?

Paul Sh

You should use begin_repeat/end_repeat but in row 12 you have repeat_group what doesn't exist so probably this is your problem.