Custom counter display within a repeated group

Hi I’m trying to display the current interaction number as a note within a repeated group, but the function position () does not seem to be working.
I tried to use a custom variable to keep track of the interactions (‘counter_init’) by first initializing the variable before the repeated group and then within the repeated group use a calculated variable (‘counter’) with the calculation ‘${counter_init}+1’ then display the ‘counter’ value in a note with the label ‘User ${counter}’. I’m not sure what I’m doing wrong!

In the form preview, for example, I enter 2 users for the first question I expect to see User 1 for the first interaction then User 2 for the second interaction

Here is the Form
users.xlsx (10.1 KB)

Welcome to the community, @rjara! You could do this as outlined in the image shared below:

In the survey tab of your XLSForm:

In the choices tab of your XLSForm:

image

Data entry screen as seen in Enketo:

Reference XLSForm:

users.xlsx (9.7 KB)

Thanks for the reply, I tried that initially but for some reason the position() function was not working for me, which is why I was trying the custom counter.

1 Like

Ok, I figured out the issue, When I used the function position, I used as position() but in the example you added the two periods position(..) So syntax was incorrect.

1 Like