# Dictionary.ByKeysValues - duplicate keys

**URL:** <https://forum.dynamobim.com/t/dictionary-bykeysvalues-duplicate-keys/45024>\
**Category:** Revit\
**Created:** [January 2, 2020, 8:17pm UTC](https://forum.dynamobim.com/t/dictionary-bykeysvalues-duplicate-keys/45024 "2020-01-02T20:17:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaveP](https://avatars.discourse-cdn.com/v4/letter/d/49beb7/32.png) [@DaveP](https://forum.dynamobim.com/u/DaveP)\
**Post date:** [January 2, 2020, 8:17pm UTC](https://forum.dynamobim.com/t/dictionary-bykeysvalues-duplicate-keys/45024/1 "2020-01-02T20:17:11Z")

</div>

I’m using a Dictionary.ByKeysValues node.  
I’m importing a spreadsheet received from a client, so I’m not surprised the data isn’t perfect.

My problem is that the node blows up completely if there are any duplicate Keys.  
Obviously, I can’t HAVE any duplicate keys, but I’m wondering if there’s some way I can make the node be a little more forgiving, and just ignore any duplicates instead of blowing the whole thing up.

They way it works now, is, if I have just a single duplicate key (in this case, out of 2400), I get 2400 null values

Is there ANY way to accept the 2399, and ignore the one?

---

<div class="post-metadata">

**Author:** ![Marcel\_Rijsmus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marcel_rijsmus/32/8539_2.png) [@Marcel\_Rijsmus](https://forum.dynamobim.com/u/Marcel_Rijsmus)\
**Post date:** [January 2, 2020, 8:56pm UTC](https://forum.dynamobim.com/t/dictionary-bykeysvalues-duplicate-keys/45024/2 "2020-01-02T20:56:29Z")

</div>

List.UniqueItems ?

---

<div class="post-metadata">

**Author:** ![DaveP](https://avatars.discourse-cdn.com/v4/letter/d/49beb7/32.png) [@DaveP](https://forum.dynamobim.com/u/DaveP)\
**Post date:** [January 2, 2020, 9:04pm UTC](https://forum.dynamobim.com/t/dictionary-bykeysvalues-duplicate-keys/45024/3 "2020-01-02T21:04:20Z")

</div>

Thanks. I had thought of that, but since my Keys are coming from one list, and my Values from another, how do I make sure that the Values are still matching the Keys after removing some of the keys?  
UniqueItems doesn’t have a “Retain index” option

---

<div class="post-metadata">

**Author:** ![jostein\_olsen](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jostein_olsen/32/8570_2.png) [@jostein\_olsen](https://forum.dynamobim.com/u/jostein_olsen)\
**Post date:** [January 2, 2020, 9:09pm UTC](https://forum.dynamobim.com/t/dictionary-bykeysvalues-duplicate-keys/45024/4 "2020-01-02T21:09:19Z")

</div>

Maybe this could work?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/f/3ff52dd7b0a16f1d0f0c9868c9eb8ecf55d4ddf8.png)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [January 2, 2020, 10:49pm UTC](https://forum.dynamobim.com/t/dictionary-bykeysvalues-duplicate-keys/45024/5 "2020-01-02T22:49:29Z")

</div>

Some nodes to think about:  
List.UniqueItems  
List.Count  
!= 1  
List.FilterByBoolMask  
List.AllIndiciesOf  
String.Join  
List.Join

Theres some added list management nodes in there too but that set should get you started. 🙂

---

<div class="post-metadata">

**Author:** ![DaveP](https://avatars.discourse-cdn.com/v4/letter/d/49beb7/32.png) [@DaveP](https://forum.dynamobim.com/u/DaveP)\
**Post date:** [January 7, 2020, 7:13pm UTC](https://forum.dynamobim.com/t/dictionary-bykeysvalues-duplicate-keys/45024/6 "2020-01-07T19:13:44Z")

</div>

Jostein; that’s exactly what I was looking for thanks!  
My graph (eventually) will be used to track what people are in which Room.  
The problem is that sometimes people share a room, or there are multiple people in one space  
The dictionary can only have one Key (the Room), so  
I added one more branch to the graph so I can report on any “extras”  
Now all I have to do it figure out how to report that back to the user. Spreadsheet, I guess

 ![MultiplesInDictionary](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/5/d5e30252ac8095c4959ce33536e12c5ab94d5d8b.png)
