Nested Repeat and not(selected) problems

Hi All,

I am trying to set up a form with a double repeat. The first repeat is for the passes (counts or observations of a species) and the second repeat is for the species observed.
i.e.
count1 - species (1 Yellow; 2 Orange; 3 Blue)
count2 - species 1 Yellow; 2 Orange; 3 Blue)

the species must not be duplicated within a count (count1 - 1 yellow…; 1 yellow…)
but can be repeated between counts ( count1 - 1Yellow…; Count2 - 1Yellow…)

I am using the following in the constraint field for the Species_ID (from select_one)

not(selected(join(’,/Repeat_NoDuplicates/RepeatPass/RepeatSpecies[./GRepeatSpecies/Species_ID and position(.) !=position(current()/…/…)]/GRepeatSpecies/Species_ID),.))

The problem I am having is that I cannot select the 2nd or 3rd species from the First Count, as the First Species on the Second Count. If I select in the same order it seems to work but there is something wrong with the constraint which I am not picking up.

I have attached an example.

Any suggestions to point me in the right direction?

Repeat_NoDuplicates.xlsx (17.1 KB)