Search for duplicates and add zyx... when duplicates exist

My goal is to set the ‘Mark’ parameter of the doors with the Number of the ‘To Room’.
But if multiple doors have the same ‘To Room’, a reverse alphabetical sequence needs to be added at the end of the Mark. If the doors ‘To Room’ is unique, nothing needs to be added.

I’ve tried searching for duplicates by listing them as unique items but it doesn’t seem to work…

I don’t really know how to continue so all help is welcome!

My dynamo so far:
POLO_DoorMarkFromToRoom.dyn (29.7 KB)

List.GroupByKey where the list is the doors and the key is the to room.

Then List.Deconstruct to pull the first item out of each sublist.

Leave the first be, add the sequence to the key, and you should be able to take it from there.

2 Likes

Thanks for your reply!
But sorry, I don’t really understand what to do with the List.deconstruct and how to add the sequence to only the duplicate key values…

POLO_DoorMarkFromToRoom.dyn (35.5 KB)

Deconstruct the sublists (list level 2). :slight_smile:

Okay, but I still don’t understand how to properly add the sequence…
Some of the doors in the ‘first’ list also need the sequence added (yellow). So I don’t really get how that helps me…
When the sublists of the ‘groups’-list contain more then one item, then the sequence needs to be added to the to room number (unique keys). If the sublists only contain 1 item, the sequence does not need to be added…

Build the sequences on top of the keys from the group by key node. Then let lacing deal with setting the values by using the ‘rest of the items’ from the deconstruct node. If there was only one item; you won’t set anything onto it. If there was 10 items, you’ll set the valine into the items in sequence.

Sorry, I still don’t quite understand your suggestion… I don’t get seperating the first item from each sublist with deconstruct while some of them also need the sequence…
I actually found another approach by counting the list items - if they are more then 1, and use that bool to choose the strings where the sequence is added to…

1 Like