How to assign each repeat group within a repeat a number label

312
5
08-21-2018 10:20 AM
Highlighted
New Contributor II

How do I capture the number of each repeat group within a repeat for a report? For example, in the attached photo log, there is a repeat. I would like each photo numbered chronologically in the report. Currently, I am asking the user to manually input the photo number of each photo, even though at the bottom of each repeat group the number is already displayed. How can I capture that number so users don't have to do it manually? Thanks.

Reply
0 Kudos
5 Replies
Highlighted
Esri Esteemed Contributor

Hi Chris,

Other users have used the once(count(${q})) function within a repeat (where ${q} is a question in the repeat, such as the image question) to capture the current index of a repeat.  Note that this does not update if a repeat is deleted mid-way through completing the form.

Reply
0 Kudos
Highlighted
New Contributor II

Hmm... I'm trying this, but the photo number for each repeat group shows "0". 

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi Chris,

The count() function excludes empty values; if using an image question as a counter (which starts empty and then is filled in), you'll want to add 1 to the value.  An alternate is to use a hidden counter in the form - see the attached file.

Reply
0 Kudos
Highlighted
New Contributor II

Got it. It’s working great now. Thanks!

Reply
0 Kudos
Highlighted
New Contributor II

Hi James,

I'm creating a new survey. I tried both of the methods discussed above to create a counter for a repeat. Both counters work great in Connect and in the 123  app on my iPad. However, neither counter works when taking the survey in Chrome. In Chrome, the once(count) counter starts each repeat at '2' and then goes down to '1' for each subsequent repeat. The once(sum) counter simply stays at '1'. I also tried taking the survey that this thread is based on in Chrome. It has the same issue. I see that in Chrome there is a counter built in that is present at the top right corner of each repeat.

Is there not a way to pull this number?

Do you know if there is a simpler, more reliable fix for this repeat counter issue in the works?

Thanks,

Chris

Reply
0 Kudos