Generate multiple choice alternatives, based on the answers in a repeat

What is the problem? Please be detailed.
I need to generate a multiple choice question (i will call it Q2), based on a previous question (Q1), Q1 asks the names of the people in the family, and my goal is that later, when i ask whom of them has a health problem, the choices be restricted to these people.
Is it possible

What ODK tool and version are you using? And on what device and operating system version?
We are using ODK Aggregate v1.4.15 windows-installer.exe, and writing on XLSForm

What steps can we take to reproduce the problem?
Just trying to write something with that concept:
To generate the choices from the answers from the answers of a previous one (ie.
Q1: Please, tell me the names of the people living at this house

  • Paul
  • Peter
  • Mary
  • Jane
    Q2: Check which of the people living here have Diabetes?

O Paul
O Peter
O Mary
O Jane

What you have you tried to fix the problem?
Just wrote using $, {var}, =, in several ways, both, in survey and in choices

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

Hello, if I understand you want that a question appear base on the response of Q1. If yes, try to use selected(${Q1}, 'XXX') where yous replace XXX by the name you want.
If i'm not not answering, pleas send a part of your xls form.

Thanks for the answer
My problem is that each family will answer different things (both, names and number of people).
I want the form to take the answer that they give, listing the family members, to generate the choices that the respondant has to answer a following question
I mean, in the question about the people having a disease in the family, each of them get the options according to the answer to the listing. This listing comes from a repeat, with an n generated from Q0
Something like: "take the name from Q1((asking for the names of the members of the family, and generate the choices for Q2 (select_multiple)
Q0 = How many people live here (integer/ name: num_fam )
Q1= Which are the names of them: (begin repeat /text/... repeat count: ${num_fam}
Here, I get one occurence (column) for each person [in reality, we ask some things about each of them, but it is not relevant for the problem]
Q2: Which of them has diabetes?
And here i would be the happiest of the Form-Writers if i can set it so that the choices here are not standardized for all, but they take the answer(s) to Q1, and transform them in a customised set of choices.
The form is in Spanish, Maybe it wouldn't be so helpful

1 Like

Very interesting question!

This is possible but as far as I know you will need to write the dynamic select one in raw XML. What I would do is create my form in XLSForm leaving that question aside, convert the form to XML and then modify the select one.

The general idea is to use an itemset that refers to your repeat in the select1. To build my example, I started with the XLSForm here. Then I replaced the definition of the select1 with:

<select1 ref="/select-one-from-repeats/people_select_one">
  <label>Select the relevant people:</label>
    <itemset nodeset="/select-one-from-repeats/people">
      <value ref="person_name"/>
      <label ref="person_name"/>

The full, functioning form: select-one-from-repeats.xml (1.8 KB)

Notice that both the value and the label use the name entered by the user. Depending on what analysis you intend to do on the resulting data, you could also consider using a calculate that gets the position in the repeat and use that as the value.


Thanks a lot.
I will try it
Best regards

Hi Anibal

I have looked at your example and attached is a sample file for the example you have just. so you can try it to see if it best solve your problem.


diabetes.xlsx (46.8 KB)



i have limited the names that will be listed in which of them has diabetes to 5 names, you can add more by creating more calculations and increasing the index repeat number to the largest number you want. example indexed-repeat(${name}, ${people}, xxxxxxx)

please try this and let us know your feedback. hope this will solve your problem now.



Thanks a lot
It works
Best regards

1 Like

Hello, i am new in odk.
Above answer work for me but displaying the person name are not limited. I need limited person. If i had only two person then other check box are empty and also it can be selected. Please help!!!!!

Thank you!!!!

please can you show the above in XLS form

Thank you Hélène for this wonderful solution. I tested it and it worked perfectly.
Is there another way to do this directly through XLS form other than editing the XML file afterwords?


Hello @Fabla. I am having the same problem. I used indexed_repeat to list answers from a single select question in a repeat into a new single select question outside the repeat but it is only piping in the value label rather than the exact wording. I am attaching what i have done and i'd be grateful if you help.Haiti V04_2_support.xlsx (19.2 KB)

@smbai, change your HC3 question type to a text instead of select one type. it will work for you

Hello, I tried the wonderfull solution Fabla suggested and that works very good!

But I would like to have the number of selected-multiple options in the selected-multiple restricted to only those names that where entered in the repeat. So if p1 and P2 and P3 where entered, i only want to have a multiple choice list of 3 names, not 5 names (of which the two last entries are empty).

So not

#1: Paul
#2: Peter
#3: Mary

But just

#1: Paul
#2: Peter
#3: Mary

So I want to restrict the number of choices in the multiple-choice list to the number of entries in the repeat.

In the case I have, the number of repeats is not known in advance.

Bart R

thank you @LN its best solution it will be great if we know how to write its xlsforms
or either how to replace actually I don't know that