Group Repeat Error

I am working on the form attached herein and I am stuck with the group repeat. The first repeat is working, however, the second one is presenting the error shown in the attached image. When I check the same on Enketo, the second repeat is duplicating the first choice.

Kindly assist with ideas on how to get the problem fixed. CSA TIMPs Actors .xlsx (87.3 KB)

You're referencing the label question from line 10 outside of its repeat group by just using ${label}.

You will need to change your syntax:

A question in a repeat can be referenced from outside the repeat with indexed-repeat(${question-name}, ${repeat-name}, index).

See the docs on Repeat Recipes and Tips for the above and other helpful details on using repeats.

Thank you @danbjoseph for taking time to write back and provide a solution.
I have been trying to implement the indexed repeat but I am getting an error about the number of arguments included.Please see the attached xlsx form. CSA TIMPs Actors .xlsx (74.7 KB)

Looked at it a little more closely than I did the first time.

  • You're getting an error about the number of arguments because you're missing one argument for the label variable. The second argument should be the repeat group name.
  • Also - loansrc, that you're referencing, does not come from a repeat group, so you don't actually need the indexed-repeat. It actually looks like the second repeat group is meant to be done once for every loansrc selected, which is the same as the first repeatgroup? Would it be simpler just to combine this into a single repeat group, rather than having two separate repeat groups?
  • Looks like you added the calculate column, and some things were shifted to the right and not under the correct column name. I tried to correct this in the example, but you should double check it.
  • It looked like the relevant column for items within the ln repeat group were just copied. While it won't hurt anything necessarily - you only need that if the criteria for appearance is different than the overall group. Having it once reduces potential errors.

You could do something like this (96.7 KB) .

2 Likes

Thank you @jwrozelle this actually works like a charm. I do not know why I had not thought of combining the repeat group before. Initially, I thought they were two sections of the questionnaire turns out they even have a much better flow when the repeat group is combined.
Again thank you very much for taking the time to go through the form.
Much appreciated.

2 Likes

No worries @TheuriKingori. The only thing I might consider from a survey design perspective after reviewing the questionnaire would be that someone might get multiple loans from the same loan source.

If you wanted to account for that, you could ask how many loans someone got from ${loansrc}. You could nest a second ln repeat-group within the repeatgroup, and have repeat_count be the number of loans from ${label}. You could still use ${label} to refer to the specific loan source within that repeat group though, without the indexed-repeat() function, as long as its within the same group.