# Group by multiple parameters

**URL:** <https://forum.dynamobim.com/t/group-by-multiple-parameters/76508>\
**Category:** Revit\
**Tags:** dynamo\
**Created:** [May 13, 2022, 12:40pm UTC](https://forum.dynamobim.com/t/group-by-multiple-parameters/76508 "2022-05-13T12:40:52Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![francis.bergeronLWHW](https://avatars.discourse-cdn.com/v4/letter/f/7feea3/32.png) [@francis.bergeronLWHW](https://forum.dynamobim.com/u/francis.bergeronLWHW)\
**Post date:** [May 13, 2022, 12:40pm UTC](https://forum.dynamobim.com/t/group-by-multiple-parameters/76508/1 "2022-05-13T12:40:52Z")

</div>

Hi guys,

I am trying to group all elements from a single level in order to assign 1 single color per level.  
However it doesnt seem to work properly since there are 2 parameters.

1. Reference level
2. Level

I tried few things ;

1. Category/Level/All elements at level/group/color ---- which lead to override node not working
2. This script;

 ![GRoup](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/3/a383d0bf75d78d05776714942649b51552274640.jpeg)

Do you guys know why it seems to “glitch” ?

---

<div class="post-metadata">

**Author:** ![francis.bergeronLWHW](https://avatars.discourse-cdn.com/v4/letter/f/7feea3/32.png) [@francis.bergeronLWHW](https://forum.dynamobim.com/u/francis.bergeronLWHW)\
**Post date:** [May 13, 2022, 12:44pm UTC](https://forum.dynamobim.com/t/group-by-multiple-parameters/76508/2 "2022-05-13T12:44:39Z")

</div>

![Levels](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/c/2c667d6537b2c3e6b890e8043802f9e4af3f6c42.jpeg)  
Here is the result

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [May 13, 2022, 12:46pm UTC](https://forum.dynamobim.com/t/group-by-multiple-parameters/76508/3 "2022-05-13T12:46:30Z")

</div>

@francis.bergeronLWHW

hi,

you can use _GroupByKe_y twice and “keying” by _workplane_ an _level_ and create a list.

KR

Andreas

---

<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:** [May 13, 2022, 1:43pm UTC](https://forum.dynamobim.com/t/group-by-multiple-parameters/76508/4 "2022-05-13T13:43:36Z")

</div>

You just need to combine the lists of values first. Some elements will use `param1` and the others will use `param2`. Use an `If` statement to combine them like so:

`param1value == "" ? param2value : param1value;`

If the value from `param1` is empty (no parameter) use the value from `param2`, otherwise use the value from `param1`.

---

<div class="post-metadata">

**Author:** ![francis.bergeronLWHW](https://avatars.discourse-cdn.com/v4/letter/f/7feea3/32.png) [@francis.bergeronLWHW](https://forum.dynamobim.com/u/francis.bergeronLWHW)\
**Post date:** [May 13, 2022, 2:32pm UTC](https://forum.dynamobim.com/t/group-by-multiple-parameters/76508/5 "2022-05-13T14:32:50Z")

</div>

Hey sir, thanks for your answer!  
I am not sure I understand tho… could you elaborate how it works? Can I use the node IF instead?

---

<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:** [May 13, 2022, 2:41pm UTC](https://forum.dynamobim.com/t/group-by-multiple-parameters/76508/6 "2022-05-13T14:41:29Z")

</div>

Yes, you can use the node instead. It’s the same logic as I mentioned above. The last sentence is an explanation of the logic represented in the codeblock (or node).

---

<div class="post-metadata">

**Author:** ![francis.bergeronLWHW](https://avatars.discourse-cdn.com/v4/letter/f/7feea3/32.png) [@francis.bergeronLWHW](https://forum.dynamobim.com/u/francis.bergeronLWHW)\
**Post date:** [May 13, 2022, 6:05pm UTC](https://forum.dynamobim.com/t/group-by-multiple-parameters/76508/7 "2022-05-13T18:05:41Z")

</div>

Yeah I clearly don’t understand. it would be like

getparameter (level) going into IF “” then getparameter (Refenrence Level) going into IF “” then getparameter (workplane) , then this one into the key?

Im so trash ahah

---

<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:** [May 13, 2022, 6:31pm UTC](https://forum.dynamobim.com/t/group-by-multiple-parameters/76508/8 "2022-05-13T18:31:45Z")

</div>

That’s basically the idea, yes. If a value is blank (`""`) you get the next parameter. You could nest this condition for as many parameters as you have. This should leave you with each element having a value from the correct parameter and allow you to group them all by key (since the keys are all valid now).

Single condition:

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

More than the one condition:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/7/67f6c7589f60f19a37905f652f3bbd9c8ddba46a.png)

---

<div class="post-metadata">

**Author:** ![francis.bergeronLWHW](https://avatars.discourse-cdn.com/v4/letter/f/7feea3/32.png) [@francis.bergeronLWHW](https://forum.dynamobim.com/u/francis.bergeronLWHW)\
**Post date:** [May 13, 2022, 7:02pm UTC](https://forum.dynamobim.com/t/group-by-multiple-parameters/76508/9 "2022-05-13T19:02:37Z")

</div>

You are a genius! i love you ! thanks brother

---

<div class="post-metadata">

**Author:** ![francis.bergeronLWHW](https://avatars.discourse-cdn.com/v4/letter/f/7feea3/32.png) [@francis.bergeronLWHW](https://forum.dynamobim.com/u/francis.bergeronLWHW)\
**Post date:** [May 16, 2022, 1:22pm UTC](https://forum.dynamobim.com/t/group-by-multiple-parameters/76508/10 "2022-05-16T13:22:29Z")

</div>

@Nick_Boyts do you know why everything works except Pipe fittings and Pipe accessories?  
both doesnt get colored but everything else is working perfectly. Is it because it is taking the “host” level?  
thanks for your help

\*SOLVED Thank you sir!
