[ODK Community] How use index-repeat()

Hi Daniel,

You can find information on how to use indexed-repeat() at
https://opendatakit.org/help/form-design/binding/ and
http://xlsform.org/ref-table/.

https://groups.google.com/forum/#!searchin/opendatakit/indexed-repeat|sort:relevance
also has lots of threads discussing it.

My recommendation is to start with the smallest form (e.g., 1-2
questions inside a repeat) and try to use indexed-repeat() so you
understand the behavior. Once you have that working, try to apply it
to your form.

Thanks,

Yaw

··· On Fri, May 12, 2017 at 11:27 AM, Daniel Couret wrote: > Hi, > > I try to know how works index-repet () > > In a loop appeal in values in cascades and choix_list or in choice_filter, I > obtain an error message asking me to use index-repet (). > > I do not have to find of clear documentation on this subject. > > Could you help me? > > Thanks > > Daniel > > -- > -- > Post: opendatakit@googlegroups.com > Unsubscribe: opendatakit+unsubscribe@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+unsubscribe@googlegroups.com. > For more options, visit https://groups.google.com/d/optout.

A big thank Yam,

I have already browsed (again and again) these documents since I began ODK,
but it is clearly necessary to say that it is not accessible to everybody!

··· ------------- XlsForm Reference Table : indexed-repeat() : Returns a single node from a nodeset by selecting the 1-based index of a repeat nodeset. It does this up to 3 repeat levels deep. indexed-repeat(nodeset arg, nodeset repeat1, int index1, [nodeset repeatN, int indexN]{0,2}) nodeset arg ? nodeset repeat1 ? int index1 ? [nodeset repeatN ? int indexN]{0,2} ? ---------------- Binding (opendatakit.org) :

It make a reference to Xpath? In node and nodeset?
It is going to need that I learn all the XML language to use ODK with a
minimum of efficiency?

I would like to stay on forms Excel and not to practice for the moment on
the .xml, even if I should make it later.

Cannot one "standardize" the language of explanation or at least make it
understandable for all?
If not a small basic dictionary would be very useful.

For the msg on ODKcommunauty
I have to look at all the messages on index-repeat() with problem and I did
not still understand how it worked especially when
the proposed corrections do not work!

We are several to ask ourselves the question and to apply without
understanding does not make party of my way make.

Cannot one have a tuto from 10 to 20 lines which would explain the
principle and implemented?

I do not ask for it specially Yam, who gives us already so much, but other
members who use this function can bring us a help.

Cordially

Dan

Hi Daniel:

Perhaps it would help us answer your questions if you provided a little
more detail on what you're trying to achieve, and maybe a sample of your
form if you can share it?

There are many things one can do with indexed-repeat, so it's difficult to
explain very quickly how to use it.

Best,
Clint

··· On Mon, May 15, 2017 at 9:09 AM, Daniel Couret wrote:

A big thank Yam,

I have already browsed (again and again) these documents since I began ODK,
but it is clearly necessary to say that it is not accessible to everybody!

XlsForm Reference Table :
indexed-repeat() : Returns a single node from a nodeset by selecting the
1-based index of a repeat nodeset. It does this up to 3 repeat levels deep.
indexed-repeat(nodeset arg, nodeset repeat1, int
index1, [nodeset repeatN, int indexN]{0,2})
nodeset arg ?
nodeset repeat1 ?
int index1 ?
[nodeset repeatN ?
int indexN]{0,2} ?

Binding (opendatakit.org) :

It make a reference to Xpath? In node and nodeset?
It is going to need that I learn all the XML language to use ODK with a
minimum of efficiency?

I would like to stay on forms Excel and not to practice for the moment on
the .xml, even if I should make it later.

Cannot one "standardize" the language of explanation or at least make it
understandable for all?
If not a small basic dictionary would be very useful.

For the msg on ODKcommunauty
I have to look at all the messages on index-repeat() with problem and I
did not still understand how it worked especially when
the proposed corrections do not work!

We are several to ask ourselves the question and to apply without
understanding does not make party of my way make.

Cannot one have a tuto from 10 to 20 lines which would explain the
principle and implemented?

I do not ask for it specially Yam, who gives us already so much, but other
members who use this function can bring us a help.

Cordially

Dan

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thnks Clint,

i am obliged to delve into the xml format, this will take me a little bit
of time.
If I still have problems I would come back to you.
Cordially
Dan

··· Le mardi 16 mai 2017 21:47:49 UTC, Clint Tseng a écrit : > > Hi Daniel: > > Perhaps it would help us answer your questions if you provided a little > more detail on what you're trying to achieve, and maybe a sample of your > form if you can share it? > > There are many things one can do with indexed-repeat, so it's difficult to > explain very quickly how to use it. > > Best, > Clint > >

Dear ODK Users,
I am facing a related situation.
I have a repeat group (details of household members) where one of the questions is age. As the form progresses, I have another group where I intend to capture information on the prevalence of WATSAN Among Under-five Children. Now I would like this second group only to show up only if in the household there is or are any children aged five years and below. Problem is, while the form seems to evaluate well in XLSForm Online, in ODK it gives an error (see attached). How can I solve this problem? I have read about Repeat Recipes and Tips, but still can't figure out what I need to do.
I have also attached a sample of the form for you to check out

impact_survey_household_questionnaire_2019.xlsx (30.2 KB) .

Thanks in advance

Hi @Musinguzi_Polycarp

the error is in cell E24 of your excel file.
You are trying to refer a repeated variable ${Q201d}, and the application does not know which iteration you want to use. At the end of the error message you have a hint, which is to use the indexed-repeat() function.

In your particular case I'd suggest two possible approaches:
a) if the second group of questions "children-under-five" refer to the expenses of the whole household, you might want to create a calculated field after the repeated group to count the number of household members below 5. The relevant condition for your group "children-under-five" would then become that this variable is greater than zero;
b) if the second group contains questions that might be relevant to each of the children, you might want to take questions Q500a-Q502 and move them into the repeated group. In this case, you could use your existing relevant condition for each of the questions (because they will be inside the loop).

I hope this helps!

Best,
Andrea

Thanks @Andrea_Martin for the tips. Option one is the most relevant in my case, but please advise on how the calculation would look like. Thanks

Any help how to get this calculation done? I have used count(${Q201d})<5, but it doesn't sem to give me the number of children in the family below the age of 5. Kindly assist

Hi @Musinguzi_Polycarp

Please find attached (impact_survey_household_questionnaire_2019_AM.xlsx (28.2 KB) ) an edited version of your form, that should address your problem.
The edits include:

  • adding a calculated field (${below5})
  • editing the relevant field to count how many children below (or equal to) 5yo are present in the household.

I hope this helps!

Best,
Andrea

Many thanks, @Andrea_Martin. One last thing, having asked the age of each household member in that repeat group, how then can calculate the number of children aged 5 and below as well as those above 5. Using if(${Q201d}<=5,1,0) only shows me that there are children aged 5 and below, but doesn't tell me how many. Similarly, count(${Q201d})<5 wasn't helping either

Hi @Musinguzi_Polycarp

To calculate the number of children below 5 you can do as per file I attached before.
There are different approaches, but the one I'm suggesting is:

  • You include in the repeat group a calculate variable "tagging" the observations you are interested in, for example the var ${below5} takes the value 1 if the age is <=5;
  • You create a calculate variable outside the repeat group summing up the values (counts) of the variables you have tagged - e.g. sum(${below5})
  • You can adapt this approach to other age brackets or variables.

Note that:

  • in the file I sent you

I skipped the creation of a new calculated variable and just included the formula in the relevant field

Best,
Andrea

Thanks, @Andrea_Martin worked fine.