Using indexed-repeat in a repeat inside a repeat

What is the problem? Please be detailed.

Hi community, the problem is when i put two or more households in the survey. As long as it is one, it does not happen. But when i put two or more, the indexed-repeat gives me a tipically error "You may need to use... bla bla bla". I use the indexed-repeat() function to show the name, surname and age of each member of each home, on the repeats labels of the modules.

What ODK tool and version are you using? And on what device and operating system version?

ODK v1.12.2, Tablet Noblex 7' Android 6.0 Marshmallow

What steps can we take to reproduce the problem?

If you put two households, and two members per home (total of four members), you will see the error when the survey goes for the second repeat per home. You'll can write the information of the members of the second home, but when the first_module starts, the error shows.

What you have you tried to fix the problem?

I read a lot of documentation. xpath, writing the xml with the current() function, and much more. But i don know how to do that things. And although there are many open topics with the same motive, none of them was useful to me.

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

Yes, i leave an example file. Complete with two households and two members per home (4 total), and you will see the error in the second repeat per home.
test.xlsx (9.2 KB)
test.xml (5.4 KB)

1 Like

Hi everyone! I resolved this using a fourth and fifth parameter in the indexed-repeat() function. This maybe can help someone else. I created an index_position for the households, which does the below: calculation=position(..). Later, in every module, i pass two parameters more to the function, the global enclosing group of the survey and the index_position.

I leave the example, maybe is useful for the community:
test.xlsx (9.2 KB)

That's my form of resolve. Anyway, i'd wish if someone more expert in ODK can tell me how to resolve this using XPath expressions. Is really interesting.

1 Like

Nicely done, @varilla! I would have done something like that as well. As you figured out, are dealing with a nested repeat at that point so you had to specify the position in both the outer repeat (home in your case) and the inner one (a module in your case).

1 Like

2 posts were split to a new topic: Compare entries using indexed-repeat