# List.GroupByFunction doesnt work with function Round. Any solutions?

**URL:** <https://forum.dynamobim.com/t/list-groupbyfunction-doesnt-work-with-function-round-any-solutions/85803>\
**Category:** Revit\
**Created:** [February 6, 2023, 2:36pm UTC](https://forum.dynamobim.com/t/list-groupbyfunction-doesnt-work-with-function-round-any-solutions/85803 "2023-02-06T14:36:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![k.kurguzov](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@k.kurguzov](https://forum.dynamobim.com/u/k.kurguzov)\
**Post date:** [February 6, 2023, 2:36pm UTC](https://forum.dynamobim.com/t/list-groupbyfunction-doesnt-work-with-function-round-any-solutions/85803/1 "2023-02-06T14:36:34Z")

</div>

Hello guys, i wanted to sort my rebar in project by diameter, then by form, then by lengths: A, B, total.  
I made already the grouping for diameter and form, but by lengths i got a problem: the values are too exact (14 digits after point) (see Page 1).

 ![Page 1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/e/7eff5887ea4b6746eeaf18977daf407c79fc00b0.jpeg)  
I try to round this value, but List.GroupByFunction doesnt accept the round as function.  
Any ideas?  
(I tried also List.GroupByKey, but it doesnt work with multi-lvl-lists)

---

<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:** [February 6, 2023, 2:40pm UTC](https://forum.dynamobim.com/t/list-groupbyfunction-doesnt-work-with-function-round-any-solutions/85803/2 "2023-02-06T14:40:08Z")

</div>

Based on your screenshot it’s not a function. Notice how `GetParameterValueByName` returns _Function_ and not values? That’s what the node is expecting. If you provide values it has nothing to apply as a function anymore.

The function gets applied to the input and the result is sorted. In your case you would have to round and sort the values but I don’t think that’s what you want. Instead, you can use `SortByKey` to sort the elements by their rounded values.

---

<div class="post-metadata">

**Author:** ![k.kurguzov](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@k.kurguzov](https://forum.dynamobim.com/u/k.kurguzov)\
**Post date:** [February 7, 2023, 8:27am UTC](https://forum.dynamobim.com/t/list-groupbyfunction-doesnt-work-with-function-round-any-solutions/85803/3 "2023-02-07T08:27:12Z")

</div>

> [@Nick\_Boyts](#):
>
> an use `SortByKey` to sort the elements by their rounded values.

Thank you for your answer.  
I want to keep the grouping (sub-lists) like it was: (grouping by 1-diameter and then by 2-form picture) And on this stage i want to add grouping by shared Parameter “RI\_A” - and it is length and too precise, that you see on picture 1.

I understand that it should work as function, (please dont pay attention on connection between them on Picture 1) and when i add rounding as a part of function it doesnt work anymore (Round cannot be a part of function it works only with “double”). I added Picture 2.

SortByKey and GroupByKey dont work with sub-lists (i tried also, it works only on first step, till i havn’t done first and second grouping)

 ![Page 2](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/3/43dffb65dec576edbc2a97e0091a52b955fb4cb0.png)

---

<div class="post-metadata">

**Author:** ![k.kurguzov](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@k.kurguzov](https://forum.dynamobim.com/u/k.kurguzov)\
**Post date:** [February 7, 2023, 8:49am UTC](https://forum.dynamobim.com/t/list-groupbyfunction-doesnt-work-with-function-round-any-solutions/85803/4 "2023-02-07T08:49:08Z")

</div>

The total idea ist to give the same value of Parameter “Mark” to Rebar instances, that have the same diameter, Form, RA, Total Length rounded to 0.1 cm.  
May be there is the better solution, that works?

---

<div class="post-metadata">

**Author:** ![k.kurguzov](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@k.kurguzov](https://forum.dynamobim.com/u/k.kurguzov)\
**Post date:** [February 7, 2023, 10:06am UTC](https://forum.dynamobim.com/t/list-groupbyfunction-doesnt-work-with-function-round-any-solutions/85803/5 "2023-02-07T10:06:43Z")

</div>

I have done the task, using ListGroupByKey at lowest level (without sub-lists) and then intersecting

 ![Page 3](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/6/36d075b23f5db084e36467cacd9b142021fa24c6.jpeg)

---

<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:** [February 7, 2023, 2:41pm UTC](https://forum.dynamobim.com/t/list-groupbyfunction-doesnt-work-with-function-round-any-solutions/85803/6 "2023-02-07T14:41:37Z")

</div>

Sorry, I meant `GroupByKey` and not `SortByKey`. Both will work on sublists with the right list levels.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/5/85974171d1e325453ae68f5f4e804cbcbbad184d.png)

> [@k.kurguzov](#):
>
> Round cannot be a part of function it works only with “double”

You can’t apply a function to a function. This is what I meant when I said you’d have to apply the round function to group the parameter values and not the elements since `GroupByFunction` uses one input for both. `GroupByKey` allows you to supply an element to group _and_ a key to group by.
