# Dynamo Sort and Group

Hi Guys,

been working on a script. I need to finish it but can’t seem to get my head around the last part. I have added the script and a screenshot of what I need.
At the end of the script I have a list op added up room area’s per building unit. Each sum has been assigned a random(?) number. But I need it to have the unit number ( “Bouwnummer”).
Hope someone can help me out.

Thnx for all the people suggesting I just use the schedules. But I need the calculated sun of all the room area’s per unit to use in further calculations. And I can’t do that with schedules.

Thnx!

Room_Area_by_department|647x500

That looks correct. The number in the list has nothing to do with your unit number. That’s just the index of the list. The total areas would be aligned with the `unique keys` output of your grouped rooms.

Hey Antonio,

Just wondering if this can be sorted out by just using the Revit schedule directly instead of adding manual numbers at every given situation?

1 Like

Hi,

yes. A schedule can be used to determine the total amount of room area per building unit. But I need the totals per unit for further calculations with a calculated parameter. That works fine when I use a manually made area plan. Because then I have 1 single area to calculate with. But I want to use the room area’s of a building unit and that consists of multiple rooms and the calculation only works on the seperate rooms, not the calculated value of all the rooms.

I hope you understand what I mean.

Hi,

thnx for the reply. Yes that is correct. I need to allign the index of the list with the correct unit numbers.
I’m really new to Dynamo so I have no clue how to do that. Which node do I place where?

I’m saying that they already are. `GroupByKey` puts all of the rooms with the same unit number in a group (sublist). When you get the areas of those rooms and sum them up (by sublist) your result is a list of total unit areas in the same order that your rooms are grouped, which is by unit. If you’re wanting to write the total area to a unit parameter then you just need to do that. Everything is already in order.

Look at the `unique keys` output and it may make things clearer.

thnx again. Yes… I can see that the end result (Math.Sum) is correct. And you’ve put it in the correct words: I want to write the total area per unit to a unit parameter… but I don’t know how to do that!

Like I said… I’m really new to this!

ps. And yes… I can see in the unique keys that the list numbers are the same as the list numbers in the Math.Sum. What I need to see is the unit number in the Math.Sum

It’s probably best you work through the Dynamo Primer then. These are all just the basics you need to know in order to be successful in Dynamo. The Primer walks you through everything and has working examples as well.

`Element.SetParameterByName`

It doesn’t work like that. Lists are just lists of items. You can’t (and don’t need to) have descriptive information in your lists. (You can kind of get around this with dictionaries, but that’s completely different and not beneficial here.) A large part of Dynamo is list management, which includes keeping separate lists in the same order so that values are aligned.

1 Like

Hi…thnx for all the feedback. Have a good weekend!