# Comparing Lists

**URL:** <https://forum.dynamobim.com/t/comparing-lists/16767>\
**Category:** Revit\
**Tags:** dynamo\
**Created:** [November 23, 2017, 12:19pm UTC](https://forum.dynamobim.com/t/comparing-lists/16767 "2017-11-23T12:19:42Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![bombear1](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/bombear1/32/31169_2.png) [@bombear1](https://forum.dynamobim.com/u/bombear1)\
**Post date:** [November 23, 2017, 12:19pm UTC](https://forum.dynamobim.com/t/comparing-lists/16767/1 "2017-11-23T12:19:42Z")

</div>

Hello everyone!

My goal is to filter a certain list, based on what element is presented in an other list.

I came up with an idea, where I compare each element of the second list with all elements of the first list one by one.

 ![logical_function](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/3/53e5fd4a7743d65dae955a1ec34ae84a53dcf025.png)

Since I don’t know the length of my second list, this is clearly not the best way of doing it.

I have two questions:

- Am I going on the right direction, or is there a better way to solve it?
- If this is the way to go, what is the right code in the codeblock, so I don’t need to add an entry for all the possible elements of the second list.

---

<div class="post-metadata">

**Author:** ![khuzaimah.ElecEng](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/khuzaimah.eleceng/32/92768_2.png) [@khuzaimah.ElecEng](https://forum.dynamobim.com/u/khuzaimah.ElecEng)\
**Post date:** [November 23, 2017, 12:50pm UTC](https://forum.dynamobim.com/t/comparing-lists/16767/2 "2017-11-23T12:50:02Z")

</div>

you could use transpose block as shown below

 ![help2](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/5/e5df44b7807efbbb3fd942b6974a1abcab56e8a0.png)

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [November 23, 2017, 12:56pm UTC](https://forum.dynamobim.com/t/comparing-lists/16767/3 "2017-11-23T12:56:13Z")

</div>

Hi @bombear1

Show us your lists.

---

<div class="post-metadata">

**Author:** ![bombear1](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/bombear1/32/31169_2.png) [@bombear1](https://forum.dynamobim.com/u/bombear1)\
**Post date:** [November 23, 2017, 1:03pm UTC](https://forum.dynamobim.com/t/comparing-lists/16767/4 "2017-11-23T13:03:15Z")

</div>

Here is my workspace.

 ![CompareLists](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/3/5327180331b2b895c5f841a0010c263254379378.png)

The yellow says: The index if out of range. (OFC it is)

---

<div class="post-metadata">

**Author:** ![bombear1](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/bombear1/32/31169_2.png) [@bombear1](https://forum.dynamobim.com/u/bombear1)\
**Post date:** [November 23, 2017, 1:03pm UTC](https://forum.dynamobim.com/t/comparing-lists/16767/5 "2017-11-23T13:03:35Z")

</div>

What is that @L1, and how to do it?

---

<div class="post-metadata">

**Author:** ![khuzaimah.ElecEng](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/khuzaimah.eleceng/32/92768_2.png) [@khuzaimah.ElecEng](https://forum.dynamobim.com/u/khuzaimah.ElecEng)\
**Post date:** [November 23, 2017, 1:09pm UTC](https://forum.dynamobim.com/t/comparing-lists/16767/6 "2017-11-23T13:09:56Z")

</div>

by click on right side arrow of the input, then check use level

this feature let you decide to deal with the whole list or sublist or sub-sublist … what ever the case you have  
 ![help23](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/c/ccf49bc8a4c1a57e443e8800f71a105a7c39660f.png)

---

<div class="post-metadata">

**Author:** ![bombear1](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/bombear1/32/31169_2.png) [@bombear1](https://forum.dynamobim.com/u/bombear1)\
**Post date:** [November 23, 2017, 1:54pm UTC](https://forum.dynamobim.com/t/comparing-lists/16767/7 "2017-11-23T13:54:36Z")

</div>

This is close to what I need, but at the end I only want TRUE-s, where it found the matching elements. So basically i need to merge the result lists, keeping all the TRUE-S

---

<div class="post-metadata">

**Author:** ![khuzaimah.ElecEng](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/khuzaimah.eleceng/32/92768_2.png) [@khuzaimah.ElecEng](https://forum.dynamobim.com/u/khuzaimah.ElecEng)\
**Post date:** [November 23, 2017, 2:08pm UTC](https://forum.dynamobim.com/t/comparing-lists/16767/8 "2017-11-23T14:08:48Z")

</div>

Try this :

 ![help3](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/c/8cb28460a3c47f4a384e7b1844d37ea2921c67ee.png)

---

<div class="post-metadata">

**Author:** ![salvatoredragotta](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/salvatoredragotta/32/10078_2.png) [@salvatoredragotta](https://forum.dynamobim.com/u/salvatoredragotta)\
**Post date:** [November 24, 2017, 3:10am UTC](https://forum.dynamobim.com/t/comparing-lists/16767/9 "2017-11-24T03:10:08Z")

</div>

Could your first list contain duplicates?

---

<div class="post-metadata">

**Author:** ![bombear1](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/bombear1/32/31169_2.png) [@bombear1](https://forum.dynamobim.com/u/bombear1)\
**Post date:** [November 25, 2017, 10:44am UTC](https://forum.dynamobim.com/t/comparing-lists/16767/10 "2017-11-25T10:44:07Z")

</div>

Yes, I forgot to mention. It does not contain duplicates.

By the way, I was able to achive the desired result with some ugly workaround (based on my first codeblock), but I’m pretty sure, the solution what is posted by @khuzaimah.ElecEng is working. I’ll try it on monday.

---

<div class="post-metadata">

**Author:** ![Thomas\_Vogt](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/thomas_vogt/32/40849_2.png) [@Thomas\_Vogt](https://forum.dynamobim.com/u/Thomas_Vogt)\
**Post date:** [January 30, 2018, 5:15pm UTC](https://forum.dynamobim.com/t/comparing-lists/16767/11 "2018-01-30T17:15:34Z")

</div>

what about [http://dictionary.dynamobim.com/#/BuiltIn/Action/SetIntersection](http://dictionary.dynamobim.com/#/BuiltIn/Action/SetIntersection) ?
