Repeat loop for multiple response not working perfectly

1. What is the problem? Be very detailed.

2. What app or server are you using and on what device and operating system? Include version numbers.

3. What you have you tried to fix the problem?

4. What steps can we take to reproduce the problem?

5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.

sector choices are: protection
-among many others.....
Question is- if i select 3 sectors, the repeat questions (questions in red) are repeated 3 times which is okay, but problem is if say is select sectors: protection, education, and shelter :What is the ${sector_intervention} sub-sector(s) of intervention? will automatically read = What is the protection education shelter sub-sector(s) of intervention? for each of the 3 responses
I would like the questions to ask for each sector in order as selected in the multiple responses.

Welcome to the ODK forum, @nomwebu ! We're glad you're here. When you get a chance, please introduce yourself on this forum thread. I'd also encourage you to add a real picture as your avatar because it helps build community!

It is possible to ask a repeat group of questions for each selected answer from a select_multiple question. And you can reference each answer inside the matching repeat to guide the respondent. You need to use the current repeat position to identify which answer you want to pull from the earlier question. The repeat position counting starts with 1 but the answer counting starts with 0, so you need to subtract 1 from the position number to get them to align. The following calculation will get you the name of the matching selected answer from the previous question:


For readability we want the label of the relevant answer, so we need to expand the above to the following:


After pulling a label using the above in a calculate type question, we can then use it in our question prompt inside the repeat. See repeat_loop.xlsx (10.7 KB) or below.

|          type           |       name        |                              label                              |                                  calculation                                  |              count              |
| select_multiple sectors | intervention      | What are the sectors of intervention?                           |                                                                               |                                 |
| begin_repeat            | sectors           | Sectors of intervention                                         |                                                                               | count-selected(${intervention}) |
| calculate               | this_sector_label |                                                                 | jr:choice-name(selected-at(${intervention},position(..)-1),'${intervention}') |                                 |
| text                    | sub_sector        | What is the ${this_sector_label} sub-sector(s) of intervention? |                                                                               |                                 |
| end_repeat              |                   |                                                                 |                                                                               |                                 |

Please make sure you read the Tip in the documentation on Repeating Questions:

Using repetition in a form is very powerful but can also make training and data analysis more time-consuming. Repeats exported from Central or Briefcase will be in their own files and will need to be joined with their parent records for analysis.

Before adding repeats to your form, ...

You will want to test your form and the data export. Make sure you understand how using repeats will affect your data output!


Amazing, thank you :smile: