How to use an indexed-repeat in a Relevant

1. What is the problem? Be very detailed.

Hello everyone

I have to filter the people who answered with certain criteria in some questions within a Repeat Group the problem is that at the time of listing the people who meet the criteria I have to do it outside of a repeat and I don't know how to perform the correct validation to this.

Hi @Over_Murillo_Chacon
Maybe something like this will help you:
irTest.xlsx (29.8 KB)

1 Like

Hi @Grzesiek2010, kindly requesting for your assistance on an almost similar scenario - but now involving a select multiple question. I want to set up a relevance (outside a repeat group) such that some questions will only be relevant to people who chose certain options within the repeat group. - please see attached sample form. I would like the questions in green font to only be relevant to people who selected either option 1, 2 or 5 on Question 4.3a (within the "pest_rpt" repeat group. I will highly appreciate your help.test_helpindexed.xlsx (15.0 KB)

Hi @mugambii

I took a look at the file you uploaded.
From the lines available, I'm not sure using the syntax "selected(...)" would give you the desired result, because the ${relev_pher} in not a select-type question. My guess is that you might get an error because the ${relev_pher} is a calculated variable, which takes a single value based on the argument included in the expression.

I'd suggest you try modifying the relevant conditions testing testing for the value of the variable, e.g. ${relev_pher}=1

I'm attaching a modified version of your file test_helpindexed_AM.xlsx (13.8 KB) .
I hope this helps!

Best,
Andrea

1 Like

Please note (to all), the selected() XPath function merely performs a (whole word) substring match against a space-separated list of values. So technically you can use it against pretty much any result (even a calculated one!), including a select_one; although for obvious reasons it would be more sensible to just use a simple equality check instead in that case; ie ${relev_pher}='1'

Which is to say, using selected() - on anything but a select_multi result - may be misguided, but it probably wont break anything.

3 Likes

Thank you very much @Andrea_Martin for taking time to look at this, and for your suggestion. Thank you too @Xiphware for your very useful guidance on this.

I am however still not getting the desired outcome - the questions with the ${relev_pher}='1' do not appear, even when the choice is selected within the repeat group. i.e Putting ${relev_pher}='1' as the relevant condition doesn't work even when choice "1" is selected. No error is displayed however. Please help.
Many thanks,

Hi @mugambii

The assumption is that the relev_pos and following lines of code are inside a repeat group. This would allow you to use the position(..) calculation.

I tested on enketo the xls form i sent you in my previous message and it seems to respond dynamically to the selections.

Also, you might want to try using ${relev_pher}=1 etc. without the apostrophes.

Best,
Andrea

Thanks a lot @Andrea_Martin

It however only works if I select one option under “non_chem” i.e either option 1, 2 or 5. If I for instance select option 1 and 2, the questions making reference to the calculated value “relev_pher” only appear for option 1, not option 2.
Also, these questions (4.4a to 4.5e) are not within a repeat group – this is probably where I’m getting the syntax all wrong?
Thank youtest_helpindexed_AM.xlsx|attachment (14.1 KB)

Hi @mugambii

Can you kindly clarify the logic of the questions, i.e.

  1. are user allowed to enter more than one pesticide per disease? in this case you should remove the repeat_count constraint for pest_rpt. also consider modifying the label for pestcide_1 which refers to "#1", while if you use a repeat you might want to make it dynamic
  2. should questions 4.4 to 4.5e be asked for each of the options selected, or they are just for the pesticide?

Best,
Andrea

Thank you @Andrea_Martin.

  1. Yes, the question on "non-chemical" methods is a multiple select, within the "pest_rpt" group - I want to establish the non-chemical control methods used for each pest problem. The questions will repeat as many times as the number of pest problems, hence the repeat count "count-selected(${pests_tomato})". I have made a slight modification to the .xlsx file - attached.
  2. Questions 4.4a to 4.5e should be relevant to people who only chose options 1, 2, or 5 - hence the calculation and ${relev_pher} relevance on these questions.test_helpindexed_AM.xlsx (13.9 KB)
    Many thanks,

Hi @mugambii

I guess you want to collect information on 4.4a-4.5d separately for each pest problem.
Assuming this is the case, I've done the following changes:

  1. Included questions 4.4 -4.6 into repeat
  2. Removed relev_pos, relev_pher (redundant)
  3. Referred pheroms to the actual choice, for each repeat/disease
  4. Changed order of questions so that they are asked together
  5. Corrected label effctv_biolog, effctv_biop, effctv_pherom so that the numbering is consistent

Modified file is attached test_helpindexed_AM_v3.xlsx (13.6 KB) .
Tested on Enketo.

I hope this helps!

Best,
Andrea

1 Like

Thanks @Andrea_Martin
I however needed these questions outside the repeat group, hence the use of indexed-repeat. I didn't want to ask them for each pest problem

Many thanks for all your help though, much appreciated