Is there a way to capture the current index of the repeating group?

I was reading the post about repeating groups here
… I have used the export to excel technique which allows one to repeat a group based on the form value and it works fine. My question is

  • Is there a way to capture the current index of the repeating group?

As an example - suppose I want a group of questions to be repeated 3 times. I can insert a column in the XLS called ‘repeat_count’ and put the number 3 in the repeat group column. I have done this and it works fine. Now what I want to capture is the repeating number of the group … maybe in a calculated field … which will hold the value 1 when my group repeats the 1st time, value 2 when my group repeats the 2nd time untill the repeat_count is reached so that when I export the data I can have a column with indexes 1,2,3 for the 3 times data was collected in the repeat group.

Can this be done in some way in kobotoolbox?

1 Like

You can use the position function. Use calculate as type. and position(…) in calculation (or position (…/…) if you are in a group below the repeat).

1 Like

Slight correction, it’s position() - (inside there are two dots, not three). I guess the forum automatically corrects two dots to three.
Had a tough time with this till I figured it out. I didn’t understand the logic of the two dots or …/… Can someone clarify?

Thanks. Yes, it’s 2 dots.

  • position() or position( 1 dot ) for this level
  • position( 2 dots ) for parent level
  • position( 2 dots/2 dots ) for grandparent level.

Depending on the repeat/group structure you have.

Could you share your final example with the community here.