End of iteration question and odk navigation

1. What is the issue? Please be detailed.
When you have a begin repeat field you can use the label column for 2 reasons

  • customize the question that asks to add an item (at the end of iteration)

  • display the contents of a variable present in the loop instead of the iteration number when using navigation in odk collect

I would like to have both at the same time

If label column is ${fruit_selected} it's ok for the second need but the question at the end of iteration is 'Ajouter " " ?
If label column is "new fruit" it's ok for the first need (question is "Ajouter new fruit?") but in odk collect the navigation is 1, 2 ...

I can't use an if statement in the column label (error on odk central??) so i test to have a calculate variable for the if statement and use this variable in the label column (${myvar}

It's not ok for the first need and the question is "Ajouter "" ?"

2. What steps can we take to reproduce this issue?
with the file
fruits_libelle_question.xlsx (12.5 KB)

Hi @Alain_Benard

There is no way to make your form work in the way you expect. In fact, I would say that you shouldn't specify the group name based on an answer from that group because then every group has a different name what doesn't make sense.
If you want to display the selected value in every repetition instead of doing that as a group name label I would rather add a note. It would be something like this:
fruits_libelle_question2.xlsx (9.4 KB)

I think your need would be best served by introducing a group as the first thing in the repeat:

type name label
begin repeat boucle_fruits Fruit
begin group groupe_fruits ${fruit_choisi}
select_one fruit fruit_choisi Choisissez un fruit
string couleur_fruit Quelle couleur
end group
end repeat

This is a special case recognized by Collect. You will see that group name used in the top-of-screen navigation and the hierarchy view:

It looks like this is not actually documented! I will add it shortly. There are other repeat tips and tricks in the documentation that you may find helpful.

Thank you Grzesiek2010 and LN. The champion is ... LN
your solution is an excellent compromise
Have a goog day.