# List.GroupBy, how to get result form rest of the list?

**URL:** <https://forum.dynamobim.com/t/list-groupby-how-to-get-result-form-rest-of-the-list/14016>\
**Category:** Lists-Logic\
**Created:** [August 15, 2017, 7:51pm UTC](https://forum.dynamobim.com/t/list-groupby-how-to-get-result-form-rest-of-the-list/14016 "2017-08-15T19:51:49Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![glenncai](https://avatars.discourse-cdn.com/v4/letter/g/dc4da7/32.png) [@glenncai](https://forum.dynamobim.com/u/glenncai)\
**Post date:** [August 15, 2017, 7:51pm UTC](https://forum.dynamobim.com/t/list-groupby-how-to-get-result-form-rest-of-the-list/14016/1 "2017-08-15T19:51:49Z")

</div>

Hi  
I have grouped points by its z value. I’am able to pull the result that I want from index of one sublist, but how can I loop thru rest of the sublist to get the result? any suggestion? Thanks  
Works:

 ![sublist works](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/f/bfa3af3bc40e697cf84c7824041e297c895f4f6b.JPG)  
Doesn’t work:  
 ![sublist not work](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/e/fe109cca988d8ab06dba9653c615468f76e1b856.JPG)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [August 15, 2017, 8:15pm UTC](https://forum.dynamobim.com/t/list-groupby-how-to-get-result-form-rest-of-the-list/14016/2 "2017-08-15T20:15:52Z")

</div>

I think you just need to put `0..3` in parenthesis. `(0..3)`  
But really you should be able to do it with levels.

---

<div class="post-metadata">

**Author:** ![glenncai](https://avatars.discourse-cdn.com/v4/letter/g/dc4da7/32.png) [@glenncai](https://forum.dynamobim.com/u/glenncai)\
**Post date:** [August 15, 2017, 8:38pm UTC](https://forum.dynamobim.com/t/list-groupby-how-to-get-result-form-rest-of-the-list/14016/3 "2017-08-15T20:38:08Z")

</div>

Thanks for reply Nick  
It still not working. same result, It only return the first list of the sub list.

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [August 15, 2017, 8:46pm UTC](https://forum.dynamobim.com/t/list-groupby-how-to-get-result-form-rest-of-the-list/14016/4 "2017-08-15T20:46:16Z")

</div>

You just want the first list of every sublist right?  
 ![image](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/3X/6/f/6f5725dfcf758c17005a79edccfba9e91f3a6a8a.png)

---

<div class="post-metadata">

**Author:** ![glenncai](https://avatars.discourse-cdn.com/v4/letter/g/dc4da7/32.png) [@glenncai](https://forum.dynamobim.com/u/glenncai)\
**Post date:** [August 15, 2017, 9:01pm UTC](https://forum.dynamobim.com/t/list-groupby-how-to-get-result-form-rest-of-the-list/14016/5 "2017-08-15T21:01:36Z")

</div>

I hope this image will explain what I want:  
 ![group](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/d/adf9a1b1aac0f52afdef6c21e01fa8c0dce2f97d.JPG)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [August 15, 2017, 9:37pm UTC](https://forum.dynamobim.com/t/list-groupby-how-to-get-result-form-rest-of-the-list/14016/6 "2017-08-15T21:37:08Z")

</div>

Then you need to go to the second level. You might also want to keep list structure depending on what you’re doing next.

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

---

<div class="post-metadata">

**Author:** ![glenncai](https://avatars.discourse-cdn.com/v4/letter/g/dc4da7/32.png) [@glenncai](https://forum.dynamobim.com/u/glenncai)\
**Post date:** [August 15, 2017, 10:45pm UTC](https://forum.dynamobim.com/t/list-groupby-how-to-get-result-form-rest-of-the-list/14016/7 "2017-08-15T22:45:01Z")

</div>

Thanks a lot Nick, It works. Is there any way to use level syntax in the code block?

---

<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:** [August 16, 2017, 3:02am UTC](https://forum.dynamobim.com/t/list-groupby-how-to-get-result-form-rest-of-the-list/14016/8 "2017-08-16T03:02:13Z")

</div>

You could try setting lacing to longest, but that can be dicey. List.map and a series of functions could also do the trick. Levels is a lot easier and faster though.

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [August 16, 2017, 12:04pm UTC](https://forum.dynamobim.com/t/list-groupby-how-to-get-result-form-rest-of-the-list/14016/9 "2017-08-16T12:04:54Z")

</div>

When in doubt, right click and use Node to Code to see the Design Script syntax.

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [August 16, 2017, 6:02pm UTC](https://forum.dynamobim.com/t/list-groupby-how-to-get-result-form-rest-of-the-list/14016/10 "2017-08-16T18:02:21Z")

</div>

> [@glenncai](#):
>
> Is there any way to use level syntax in the code block?

![20170816-2](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/d/2d541bbd8f7f70bee6d663d25eed9bbe092c64c7.png)

---

<div class="post-metadata">

**Author:** ![glenncai](https://avatars.discourse-cdn.com/v4/letter/g/dc4da7/32.png) [@glenncai](https://forum.dynamobim.com/u/glenncai)\
**Post date:** [August 16, 2017, 6:05pm UTC](https://forum.dynamobim.com/t/list-groupby-how-to-get-result-form-rest-of-the-list/14016/11 "2017-08-16T18:05:56Z")

</div>

what a awesome trick:+1:
