Choice-filter in a loop - with condition based on position

Hi everyone.

I’m working on a form with a loop, and I need to filter the response options based on the loop “subject” (or position). The form works well in the first loop but doesn’t in the others. I’m currently working with a “selected-at” in the “choice-filter”; I’ve also tried the “filter” and “cascading” options, and took a look at “current()” but couldn’t figure it out.

My loop is based on the # of visible elephants, and for each of them, I want to know who the nearest neighbor is. In the options, I only want to include the elephants that were previously selected, except for the elephant that we are currently assessing in the loop.

In the choice-filter I’m adding this function based on my previous variable “visible-elephant”, which was the select-multiple question for the loop:
(selected(${visble_elephants}, name)) and not(selected(selected-at(${visble_elephants},position(…)-1), name))

I believe the problem comes at the “position(…)-1”, as it is not dynamically changing. Any clues on this?

Welcome @paolagomez!
Could you provide an extract of your form, please?
I trust the form was checked already with the online validator.

Maybe select_from_repeat can also help you. See Select-one-from-repeats not supported in KoBoToolbox - #9 by Kal_Lam
(If you use it, pretest the data export also.)

And using the search function of the forum you will find other examples for similar select demands. See

But there seem to be few unsolved bugs with repeats also, see

Hi Wroos,

Thanks for your answer! and for sharing potential solutions.

Unfortunately I cannot attach any files (apparently new users can’t upload attachments).

Alternatively here is the link to my “survey” tab; please note that choices only include the names of the elephants:

Thank you in advance.

To locate the problem:
Could you test,

  • if it works when you hardcode the position(…)-1 expression your choice filter, e.g. as 1 or 2?
  • if it works in online validator preview?
  • if it works with ODK/Kobo Collect?

@Kal_Lam may help for your upload/attach rights, please.

Could you share a screenshot of this please so that the community could further understand?

Hi Wroos and Kal_Lam, thanks for your follow-up!

To answer your questions @Wros, yes I’ve played with the position and it works fine, as well as the online validator, and I’m currently using Kobo and I don’t get any error messages.

To make this a bit clearer here is the screenshot of my loop. You’ll see in the “verification note” that the second loop is not working properly.

I’m still unable to upload any file, I’m getting an error message “Sorry, new users can not upload attachments” (@Kal_Lam, any ideas on how to fix this?). Alternatively in the google sheets link I left above you’ll find the form (and the screenshot) for your reference.