Select to view content in your preferred language

Index on nested repeat

289
3
11-22-2024 01:23 PM
DouglasKnabe
Occasional Contributor

I've got a nested repeat, and am trying to create an index on the inner repeat that rolls over from the previous outer repeat. (see table below) I've got a field ${repindex} using position(..) within the inner repeat, a field (${currMax}) equal to max(${repindex}) in the outer repeat, then a sum(${currMax}) outside the repeats, which is then referenced in the display of the inner repeat. It doesn't quite work as intended, especially when I cycle back to previous repeats. Any ideas?

i.e.

Outer repeat ValueInner Repeat Value

rollover index

a41
a22
a63
b34
b25
c16
c77
c88

Ideally, the rollover index would recalculate if a record is added or deleted in the middle.

0 Kudos
3 Replies
DougBrowning
MVP Esteemed Contributor

One trick to not recalc on you is once(position()).  But note position has issues when it is nested.  Check to make sure you are not getting a loop error at the top right on Connect.  If you do I had to go back to the old way of once(count(dummyfield of 1)).

To get the sum or max correct it has to be 1 level above what you want to count.  It does get tricky in nested.  But just roll up as you go.

But big note all of this falls apart if the user goes back a few records in the repeat and deletes a record.  Then you got a dup.  We mostly just stopped using indexes.  In an attribute table they order how they were added anyway so we just don't really need them anymore.

0 Kudos
DouglasKnabe
Occasional Contributor

Thanks. The index is more for display to help line up with what is currently a paper form that we are transcribing via Survey123. The nested repeat is more to add convenience, so I may just give the end user group an either/or choice.

0 Kudos
abureaux
MVP Frequent Contributor

This could also be a case of poorly formatted calculates. Once() would likely still help, but restructuring the calculates could be a better option. Any chance you can include the XLSX?

EDIT: Also, what is the intent here?

0 Kudos