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 Value | Inner Repeat Value | rollover index |
a | 4 | 1 |
a | 2 | 2 |
a | 6 | 3 |
b | 3 | 4 |
b | 2 | 5 |
c | 1 | 6 |
c | 7 | 7 |
c | 8 | 8 |
Ideally, the rollover index would recalculate if a record is added or deleted in the middle.
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.
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.
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?