# Repeat with multiple selection

**URL:** <https://forum.getodk.org/t/repeat-with-multiple-selection/3102>\
**Category:** Support\
**Created:** [April 14, 2014, 11:41am UTC](https://forum.getodk.org/t/repeat-with-multiple-selection/3102 "2014-04-14T11:41:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eddy\_Rellum](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/e/45deac/32.png) [@Eddy\_Rellum](https://forum.getodk.org/u/Eddy_Rellum)\
**Post date:** [April 14, 2014, 11:41am UTC](https://forum.getodk.org/t/repeat-with-multiple-selection/3102/1 "2014-04-14T11:41:10Z")

</div>

Dear all,

Can anyone send me an example (xls) with a repeat with multiple selection.  
I want to create a form with a list of multiple herbicides and do some  
repeating questions for each herbicide that is selected. There was some  
discussion topic on this, but I can't get this thing work in my excel. Most  
of the discussion there is on the Xform-level, for which I don't have  
enough experience... Would be good to have an example form... Many thanks  
in advance!

Kind regards,

Ed

---

<div class="post-metadata">

**Author:** ![Eddy\_Rellum](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/e/45deac/32.png) [@Eddy\_Rellum](https://forum.getodk.org/u/Eddy_Rellum)\
**Post date:** [April 14, 2014, 1:49pm UTC](https://forum.getodk.org/t/repeat-with-multiple-selection/3102/2 "2014-04-14T13:49:46Z")

</div>

Dear all,

I solved it. I included the excel file for others that might want to  
include this functionally in their forms.

Kind regards,

Ed

[Test\_looping\_with\_select\_multiple\_v9.xls](https://getodk.b-cdn.net/uploads/default/original/1X/4749ea74252ad2d2e5027cec7b1fcc26554a8188.xls) (62 KB)

> **···**
>
> On Monday, April 14, 2014 1:41:10 PM UTC+2, Eddy Rellum wrote: \> \> Dear all, \> \> Can anyone send me an example (xls) with a repeat with multiple selection. \> I want to create a form with a list of multiple herbicides and do some \> repeating questions for each herbicide that is selected. There was some \> discussion topic on this, but I can't get this thing work in my excel. Most \> of the discussion there is on the Xform-level, for which I don't have \> enough experience... Would be good to have an example form... Many thanks \> in advance! \> \> Kind regards, \> \> Ed \>

---

<div class="post-metadata">

**Author:** ![Mitch\_S](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/m/3ec8ea/32.png) [@Mitch\_S](https://forum.getodk.org/u/Mitch_S)\
**Post date:** [April 14, 2014, 8:26pm UTC](https://forum.getodk.org/t/repeat-with-multiple-selection/3102/3 "2014-04-14T20:26:31Z")

</div>

Hi Eddy,

A word of caution: When using repeat groups in your forms, _be sure to test  
the form by filling out 2 or more instances of each repeat group within the  
same filled-in form_.

XLSForm expands ${q1} to the full absolute reference to the field, e.g.,  
/myform/repeat1/q1

When you add the second copy of the repeat group, this will expand to refer  
to a list of two values -- the first repeat's value and the second repeat's  
value.

And this often crashes the form's constraint, relevant or calculate  
expressions.

The fix is to replace ${q1} in those broken expressions with relative  
references to these values, e.g., in a constraint for /myform/repeat1/q2,  
rather than refer to ${q1}, the constraint should refer to ../q1 -- the  
value of q1 within this same copy of the repeat group.

These are tricky to discover and correct.

> **···**
>
> ----------- Mitch
> 
> On Mon, Apr 14, 2014 at 6:49 AM, Eddy Rellum [4estsense@gmail.com](mailto:4estsense@gmail.com) wrote:
> 
> > Dear all,
> > 
> > I solved it. I included the excel file for others that might want to  
> > include this functionally in their forms.
> > 
> > Kind regards,
> > 
> > Ed
> > 
> > On Monday, April 14, 2014 1:41:10 PM UTC+2, Eddy Rellum wrote:
> > 
> > > Dear all,
> > > 
> > > Can anyone send me an example (xls) with a repeat with multiple  
> > > selection. I want to create a form with a list of multiple herbicides and  
> > > do some repeating questions for each herbicide that is selected. There was  
> > > some discussion topic on this, but I can't get this thing work in my excel.  
> > > Most of the discussion there is on the Xform-level, for which I don't have  
> > > enough experience... Would be good to have an example form... Many thanks  
> > > in advance!
> > > 
> > > Kind regards,
> > > 
> > > Ed
> > 
> > ## --
> > 
> > Post: [opendatakit@googlegroups.com](mailto:opendatakit@googlegroups.com)  
> > Unsubscribe: [opendatakit+unsubscribe@googlegroups.com](mailto:opendatakit+unsubscribe@googlegroups.com)  
> > Options: [http://groups.google.com/group/opendatakit?hl=en](http://groups.google.com/group/opendatakit?hl=en)
> > 
> > * * *
> > 
> > You received this message because you are subscribed to the Google Groups  
> > "ODK Community" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [opendatakit+unsubscribe@googlegroups.com](mailto:opendatakit+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> Mitch Sundt  
> Software Engineer  
> University of Washington  
> [mitchellsundt@gmail.com](mailto:mitchellsundt@gmail.com)

---

<div class="post-metadata">

**Author:** ![Eddy\_Rellum](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/e/45deac/32.png) [@Eddy\_Rellum](https://forum.getodk.org/u/Eddy_Rellum)\
**Post date:** [June 9, 2014, 11:46am UTC](https://forum.getodk.org/t/repeat-with-multiple-selection/3102/4 "2014-06-09T11:46:28Z")

</div>

Hi Mitch,

Could you give me an example your solution (see below), by for example  
using the form that I uploaded for this post? I do not understand it  
entirely. Would be great, but if you don't have time for this, I will  
understand. Thanks in advance.

Kind regards,

Eddy

> **···**
>
> On Monday, April 14, 2014 10:26:31 PM UTC+2, Mitch Sundt wrote: \> \> Hi Eddy, \> \> A word of caution: When using repeat groups in your forms, \*be sure to \> test the form by filling out 2 or more instances of each repeat group \> within the same filled-in form\*. \> \> XLSForm expands ${q1} to the full absolute reference to the field, e.g., \> /myform/repeat1/q1 \> \> When you add the second copy of the repeat group, this will expand to \> refer to a list of two values -- the first repeat's value and the second \> repeat's value. \> \> And this often crashes the form's constraint, relevant or calculate \> expressions. \> \> The fix is to replace ${q1} in those broken expressions with relative \> references to these values, e.g., in a constraint for /myform/repeat1/q2, \> rather than refer to ${q1}, the constraint should refer to ../q1 -- the \> value of q1 within this same copy of the repeat group. \> \> These are tricky to discover and correct. \> ----------- \> Mitch \> \> \> \> On Mon, Apr 14, 2014 at 6:49 AM, Eddy Rellum \<4est...@gmail.com \> wrote: \> \>\> Dear all, \>\> \>\> I solved it. I included the excel file for others that might want to \>\> include this functionally in their forms. \>\> \>\> Kind regards, \>\> \>\> Ed \>\> \>\> On Monday, April 14, 2014 1:41:10 PM UTC+2, Eddy Rellum wrote: \>\> \>\>\> Dear all, \>\>\> \>\>\> Can anyone send me an example (xls) with a repeat with multiple \>\>\> selection. I want to create a form with a list of multiple herbicides and \>\>\> do some repeating questions for each herbicide that is selected. There was \>\>\> some discussion topic on this, but I can't get this thing work in my excel. \>\>\> Most of the discussion there is on the Xform-level, for which I don't have \>\>\> enough experience... Would be good to have an example form... Many thanks \>\>\> in advance! \>\>\> \>\>\> Kind regards, \>\>\> \>\>\> Ed \>\>\> \>\> -- \>\> -- \>\> Post: opend...@googlegroups.com \>\> Unsubscribe: opendatakit...@googlegroups.com \>\> Options: http://groups.google.com/group/opendatakit?hl=en \>\> \>\> --- \>\> You received this message because you are subscribed to the Google Groups \>\> "ODK Community" group. \>\> To unsubscribe from this group and stop receiving emails from it, send an \>\> email to opendatakit...@googlegroups.com . \>\> For more options, visit https://groups.google.com/d/optout. \>\> \> \> \> \> -- \> Mitch Sundt \> Software Engineer \> University of Washington \> mitche...@gmail.com \>

---

<div class="post-metadata">

**Author:** ![Mitch\_S](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/m/3ec8ea/32.png) [@Mitch\_S](https://forum.getodk.org/u/Mitch_S)\
**Post date:** [June 9, 2014, 6:03pm UTC](https://forum.getodk.org/t/repeat-with-multiple-selection/3102/5 "2014-06-09T18:03:56Z")

</div>

I don't have time.

Generate the XML from your XLS.

Then view the XML in a text editor (e.g., Notepad++).

The XML structure is described here:

> **[ODK Forms](https://docs.getodk.org/form-design-intro/)**
>
> Forms provide a structured way to collect and provide information. Typically forms are used by data collectors (also called enumerators) with the Collect app who ask questions of and share informat...

The repeat group of your form will contain within it the fields for the  
questions you are referencing. E.g.,

```
  <instance>
    <data id="exampleForm">
      <household_id/>
      <members>
        <name/>
        <age/>
        <education/>
      </members>
    </data>
 </instance>

```

If your form referenced ${age} it would be expanded to /data/members/age in  
the XML. Look at these expansions in your form.

The problem is that /data/members is a repeat group. If you need to  
reference the age of the member being interviewed in order to prompt for  
the value of the education field, you need to use a relative path to  
reference that age; ${age} ( /data/members/age in the XML ) will return a  
set of all ages, which is not what you want.

If you are on the 'education' question for the 2nd member of the household,  
these are equivalent expressions:

../age == /data/members[2]/age  
../age == /data/members[position(..)]/age  
../name == /data/members[2]/name  
../name == /data/members[position(..)]/name

If the 1st member had an age of 14 and the 2nd member had an age of 6, then

/data/members/age (i.e., ${age} ) will refer to the set of values { 14, 6  
} and there are not many functions in ODK Collect that can manipulate sets.

> **···**
>
> On Mon, Jun 9, 2014 at 4:46 AM, Eddy Rellum \<4estsense@gmail.com\> wrote:
> 
> > Hi Mitch,
> > 
> > Could you give me an example your solution (see below), by for example  
> > using the form that I uploaded for this post? I do not understand it  
> > entirely. Would be great, but if you don't have time for this, I will  
> > understand. Thanks in advance.
> > 
> > Kind regards,
> > 
> > Eddy
> > 
> > On Monday, April 14, 2014 10:26:31 PM UTC+2, Mitch Sundt wrote:
> > 
> > > Hi Eddy,
> > > 
> > > A word of caution: When using repeat groups in your forms, _be sure to  
> > > test the form by filling out 2 or more instances of each repeat group  
> > > within the same filled-in form_.
> > > 
> > > XLSForm expands ${q1} to the full absolute reference to the field, e.g.,  
> > > /myform/repeat1/q1
> > > 
> > > When you add the second copy of the repeat group, this will expand to  
> > > refer to a list of two values -- the first repeat's value and the second  
> > > repeat's value.
> > > 
> > > And this often crashes the form's constraint, relevant or calculate  
> > > expressions.
> > > 
> > > The fix is to replace ${q1} in those broken expressions with relative  
> > > references to these values, e.g., in a constraint for /myform/repeat1/q2,  
> > > rather than refer to ${q1}, the constraint should refer to ../q1 -- the  
> > > value of q1 within this same copy of the repeat group.
> > > 
> > > ## These are tricky to discover and correct.
> > > 
> > > Mitch
> > > 
> > > On Mon, Apr 14, 2014 at 6:49 AM, Eddy Rellum [4est...@gmail.com](mailto:4est...@gmail.com) wrote:
> > > 
> > > > Dear all,
> > > > 
> > > > I solved it. I included the excel file for others that might want to  
> > > > include this functionally in their forms.
> > > > 
> > > > Kind regards,
> > > > 
> > > > Ed
> > > > 
> > > > On Monday, April 14, 2014 1:41:10 PM UTC+2, Eddy Rellum wrote:
> > > > 
> > > > > Dear all,
> > > > > 
> > > > > Can anyone send me an example (xls) with a repeat with multiple  
> > > > > selection. I want to create a form with a list of multiple herbicides and  
> > > > > do some repeating questions for each herbicide that is selected. There was  
> > > > > some discussion topic on this, but I can't get this thing work in my excel.  
> > > > > Most of the discussion there is on the Xform-level, for which I don't have  
> > > > > enough experience... Would be good to have an example form... Many thanks  
> > > > > in advance!
> > > > > 
> > > > > Kind regards,
> > > > > 
> > > > > Ed
> > > > 
> > > > ## --
> > > > 
> > > > Post: [opend...@googlegroups.com](mailto:opend...@googlegroups.com)  
> > > > Unsubscribe: [opendatakit...@googlegroups.com](mailto:opendatakit...@googlegroups.com)
> > > > 
> > > > Options: [http://groups.google.com/group/opendatakit?hl=en](http://groups.google.com/group/opendatakit?hl=en)
> > > > 
> > > > * * *
> > > > 
> > > > You received this message because you are subscribed to the Google  
> > > > Groups "ODK Community" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an email to [opendatakit...@googlegroups.com](mailto:opendatakit...@googlegroups.com).
> > > > 
> > > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > > 
> > > --  
> > > Mitch Sundt  
> > > Software Engineer  
> > > University of Washington  
> > > [mitche...@gmail.com](mailto:mitche...@gmail.com)
> > 
> > ## --
> > 
> > Post: [opendatakit@googlegroups.com](mailto:opendatakit@googlegroups.com)  
> > Unsubscribe: [opendatakit+unsubscribe@googlegroups.com](mailto:opendatakit+unsubscribe@googlegroups.com)  
> > Options: [http://groups.google.com/group/opendatakit?hl=en](http://groups.google.com/group/opendatakit?hl=en)
> > 
> > * * *
> > 
> > You received this message because you are subscribed to the Google Groups  
> > "ODK Community" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [opendatakit+unsubscribe@googlegroups.com](mailto:opendatakit+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> Mitch Sundt  
> Software Engineer  
> University of Washington  
> [mitchellsundt@gmail.com](mailto:mitchellsundt@gmail.com)
