Error in repeat group: "Unable to evaluate `position` on [...], which is empty."

I would like to have a repeat group for each of the answers selected in a previous question. Below are the issues I can't solve:

  • I get the following error: "Calculation Error: Error in calculation for /data/repeat_activity/activity_number Unable to evaluate position on /data/repeat_activity[1], which is empty."

  • ${activity} seems to stay the first option selected in ${WPU_activity} for each repeat group.

Thanks!

https://confluence.dimagi.com/display/commcarepublic/Advanced+Functions+for+Repeat+Groups

you might need to adjust your code slightly to include the parent function into the position function. so, to say position(..) instead.

Thanks for your answer. Could you please share more details? I'm not sure to see how to adjust the syntax.

Thanks!

Basically position needs an argument to figure out which position to return.
if you are in a repeat group, and you want to get the position of the current repeat, you want to say position(..) + 1
if you have a repeat inside another repeat, you would type position(../..) instead.
it's a weird syntax that you should experiment with until you get what you need.