Unique elements in sublists

hello everyone,

i need your help. I have 1 list with few sublists. The content of the sublists overlap a little bit.
Now i want to create a new list, with the same sublists but only with unique elements from the whole list. I tried setdifference with various levels, but that didn’t work. Please see my screenshot below.

one solution could be:
In “0 List” are always only unique elements, so i have to compare “1 List” with “0 list” an delete all elements which are the same to “0 list” from “1 List” and so on…

Hope you can help

Hi @d.nimfuehr !
Maybe this rough process diagram will help you :

You’re probably going to want to do this in python, especially if your lists are going to vary is size/number. You just need to keep track of an existing list of values that you’ve already included in your sublists. Iterate through each item in each sublist. If that item already exists in you your existing list, skip it. If it’s a new item, keep it in the sublist and then add it to the existing list.

Maybe this topic can help:

Non-python method, but does require clockwork for the multiple replacement. There’s probably a cleaner way to rebuild the list structure but this should get you started.

Edit: Actually use Daan’s link above, the solutions are far more elegant.

It looks like it works that way

I have made some change compared to my previous diagram, i figured out it is not about “contains” but more about “difference”, and no need of FilterByBoolMask…

@d.nimfuehr @Robert_Younger @Francois_Labonne Here is another solution with few lines of python code:


lst1 = List.TakeItems(lst,0..List.Count(lst)-1);
lst2 = List.Flatten(lst1<1>,-1);
lst3 = List.SetDifference(lst,lst2);

With nodes…

uniqueItems.dyn (10.7 KB)


Thanks guys you are awesome.
By the way I used the Python Script from @Kulkul. It worked perfectly.

best, daniel