Select to view content in your preferred language

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

1446
5
08-21-2018 10:20 AM
ChrisShuck1
Emerging Contributor

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.

0 Kudos
5 Replies
JamesTedrick
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.

0 Kudos
ChrisShuck1
Emerging Contributor

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

0 Kudos
JamesTedrick
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.

0 Kudos
ChrisShuck1
Emerging Contributor

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

0 Kudos
ChrisShuck1
Emerging Contributor

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

0 Kudos