Restrict choices already selected from a repeat group

Hi @an_ju,

Have you considered using a choice filter rather than constraints? Here’s something that might work for your situation:

survey

type name label calculation choice_filter
calculate c1 concat(${visit})
begin_repeat visits Visits
calculate c2 substr(${c1}, 0, position(…) - 1)
select_one visits visit Visit not(contains(${c2}, name))
end_repeat

choices

list_name name label
visits 0 Visit 3A
visits 1 Visit 3B
visits 2 Visit 3C

choice-filter-repeat-group.xlsx (6.0 KB)

4 Likes

Hey Josh,

Sorry for the late response… And thank you for this view. I did not try this. Appreciate it very much.

sir what i had wanted was that if the option ‘One’ is selected, it should not show in subsequent repeats
e.g in first repeat if “One” is selected, second repeat should only display all other options except the option “One” which was selected
if “Two” is also selected in second repeat, both options “One” and “Two” should not display in subsequent repeats,
the repeat should continue until the all options are selected, then repeat ends at last option selected

Hi @yendor,

Josh’s solution seems exactly like what you asked. Can you elaborate on your question?

1 Like

thank you sir
but this does not work for select multiple in the first repeat, when i replaced the select one with select multiple in first repeat, it does not work
3choice_filter-display options not selected in next question.xlsx (62.5 KB)
attached is what I’ve tried but its not working too

Hi @yendor,

Do you think this might help you?

1 Like

Hi, This example from Josh would be perfect if I can get it to work.
The example as it stands does not remove a selected option after a few (I think 3) repeats. I made the select_one options list longer in the attached example and have modified the example a bit. It seems to be working now, but if i make the select_one required i cannot save it it seems to be ‘removing’ the second answer and i cannot continue.

It would be great if i could get this to work as it solves many enumerator problems.

Thanks
choice-filter-repeat-group Modified.xlsx (10.9 KB)

Would you mind, please, to avoid posting the same issue, probably for the same project, twice to the community?
See Eliminating selected options after selected once in repeat group - #5 by Rusti

Genial!!, excelente ayuda
Saludos desde Ecuador

1 Like

Hi @Josh, @Kal_Lam

I tried your example and it worked perfectly. Unfortunately, I added up to 11 choices which does work if the choices are more than 9. How to fix this ? As a new user I can not upload the test file.

Hi @Josh and @Kal_Lam.

I’m also having the same issue. If I add more than 10 options, when the user comes to the 10th item, it gets repeated values for those that are remaining (or the former selection are not fixed). How should I approach this issue? Is this related to the calculation field of C2?

Thanks.

Hi @vick25 and @rrmaximiliano, thank you for flagging this. You can just use letters instead of numbers for the choice names (the formula as I wrote it only works on single letter-length choice names):

survey

type name label calculation choice_filter
calculate c1 concat(${visit})
begin_repeat visits Visits
calculate c2 substr(${c1}, 0, position(…) - 1)
select_one visits visit Visit not(contains(${c2}, name))
end_repeat

choices

list_name name label
visits a Visit 3A
visits b Visit 3B
visits c Visit 3C
visits d Visit 3D
visits e Visit 3E
visits f Visit 3F
visits g Visit 3G
visits h Visit 3H
visits i Visit 3I
visits j Visit 3J
visits k Visit 3K
visits l Visit 3L
visits m Visit 3M

choice-filter-repeat-group-alpha.xlsx (9.9 KB)

3 Likes

Hi Kal Lam,

Hope you are doing well. My name is Rony, and, first, my apologies for sending this email impromptu, but I found one of your solutions while searching for a question about restricting choices already selected from a repeat group on KoboToolbox. And I was wondering if you happen to have another solution for that problem when you have more than 10 choices.

A bit of background, we are implementing a program in Ukraine for students that need tutoring classes, and the tutors need to provide feedback. In some cases, the group of students consists of 10+ kids, and when I implemented your solution in the link above it seems that I am not able to make it fully functional after the 10th kid. So, for example, the 11th and 12th kids are not removed when I get to the 13th kid.

Thank you very much in advance, and regardless of your message, I appreciate the solutions you have posted overall in the kobo forum.

Cheers,
Rony Rodrigo Maximiliano Rodríguez-Ramírez

Hi @Kal_Lam ,
I try to follow and modify your approach based on my need but , but I faced an error on the constraint when the repeat group more than 2 group. Kindly need help.

Please see capture below :

If you my screen capture above, All class that selected are different, but value still not allowed.

Here the my xls file

Hi @Josh ,
is there anything that we can do to apply multiple choice filter, for instance in my case the previous selection is not hide.
I use this choice filter : selected(${school},filter) and not(contains(${C2}, name)), since I need to cascade the class as well by school

hi @Kal_Lam ,
There is an error with the function
I download the example, and tried.

I found that even of all selection are different in each fields, the constraint still work. please see the capture below

@rrmaximiliano @Josh,
You might use other fixed naming for the choices, e.g. 2 “digits”/characters like ‘01’ … ‘99’, and adapt the substring calculation. Important here is that all choice names have the same length.

And you might use single characters, incl. lteters, like ‘1’ … ‘9’, 'a … ‘z’, ‘A’ … ‘Z’.

@taufik_maggangka,
Could you, please, share a related part of your form, incl. used choices?

I found a workaround, that works only when entering data for the first time in the repeat group but not after
so the constraint will work while entering data but will stop after moving on to the next repeat.
(the only catch is that all the choices should be the same length)

the solution is shown in the image: (thanks to @Kal_Lam, I used his xlsform)

it worked for me on kobocollect android.

Hey Josh,
This is something that I have been looking for. I tried it, but unfortunately, mine does not eliminate the choices that have already been selected. I am using a csv file for the choice list.
I would like to share with you my files so that you have a look at it. How can I share them?

Thanks