Select to view content in your preferred language

Survey123 repeat position - avoid double counting on repeat removal

376
2
12-04-2023 02:58 PM
ChristopherCounsell
MVP Regular Contributor

Hi,

Have a survey with a repeat. We'd like to calculate the position of each repeat so that becomes the ID. e.g.

repeat
ID
ID name
End repeat

Gives an outcome like

1Name 1
2Name 2
3Name 3

 

We can use the position(..) calculation to calculate the ID number within the repeat. 

If a user collecting data deletes a repeat, we could use the Once(position(..)) calculation to prevent the ID from changing. However, a new repeat will potentially re-use the same position value. e.g. for the above scenario, if we remove the second repeat entry and entry a new one, the table will look like:

1Name 1
3Name 3
3Name 4
  

 

We can't re-calculate all the IDs as they are referenced in questions later on in the survey.

We want the re-entry to take the 4th position. So looking for ways we could resolve this e.g.

  • Different calculation method for position(..)
  • Prevent users from deleting repeat entries
  • External calculation/function to track highest value entered across repeat IDs and then +1 into new repeat (without somehow causing a loop)
  • Other suggestions

@DougBrowning @IsmaelChivite would really appreciate your eyes on this one 🙂

Cheers

0 Kudos
2 Replies
DougBrowning
MVP Esteemed Contributor

We get this on the regular.  If they go back a few and delete all the counting is off as you said.  We also have issues where they go back and change stuff.

No way around it really we just had to train our crews to not do that.

0 Kudos
abureaux
MVP Regular Contributor

I would also love an answer to this (for a different reason though).

I'd just love for repeats to have a "recalculate" option and force their calculates to do their thing again. Adding calculationMode=always to a repeat would be neat (but I can see that bogging things down after a while).

0 Kudos