r/ExcelPowerQuery • u/the_1975_21stcentury • Nov 06 '25
Rolling up entries in multiple columns by using column of duplicate references
Hi, I've managed to create a Power Query containing different tables of occupancy data for different weeks, that use the same location reference. The occupancy data occupies many columns as it is recorded on an hourly basis. Which functions could I use to aggregate the occupancy data for all of those columns, based on a single, unique room reference shown in the column highlighted with the green fill, below? i.e. I have multiple room 101 entries with data populating columns relating to the record for each week. There are multiple entries in that column relating to 101, but the occupancy data is effectively staggered down and across the columns to the right.

2
u/declutterdata Nov 10 '25
I wrote you a little example, hope that helps. Short explanation
Table.AddColumn to add your total
Record.ToTable to transform every row into a table
Table.SelectRows to filter out cols that shouldn't be aggregated
List.Sum to sum up the values
Take PQ Formatter to format the code. I formatted it properly, but Reddit code block is a bit weird for me.
letSource = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("NYzJDQAgDMN26ZtHw80sFfuvQUvgZTmWYiaQJFlVHYWogZ1Mskvj1onxU3GZ3BYB/a2GvUu8T+DWfQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Jan = _t, Feb = _t, Mrz = _t]),Formatting = Table.TransformColumnTypes(Source,{{"Jan", Int64.Type},{"Feb", Int64.Type},{"Mrz", Int64.Type}}),AddingTotal = Table.AddColumn(Formatting,"Total",each let Table = Record.ToTable(_), Filter = Table.SelectRows(Table, each [Name] <> "ID"), Sum = List.Sum(Filter[Value]) in Sum)inAddingTotal
Best regards,
Phillip | DeclutterData 🙋🏻♂️
1
u/the_1975_21stcentury Nov 13 '25
Thank you. This was my workflow in the end:
Used a routine to create tables from each of the spreadsheet tabs, saving each as an xlsx (VBA routine)
Added a helper column in PowerQuery to identify only those tables in the imported data, for each building and weekly dataset. See screenshot below.
Expanded the helper column to show all the expanded table data and timeslots
Filtered the timeslots for the working day hours that were of interest
Closed and Loaded to...
Used Excel consolidate function to bunch the data by timeslot and ensure I have data against each unique room reference
Used conditional formatting to create a heat chart of occupied rooms