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.

1
u/the_1975_21stcentury Nov 13 '25
Thank you. This was my workflow in the end:
2
u/declutterdata Nov 10 '25
Hi u/the_1975_21stcentury ,
I wrote you a little example, hope that helps. Short explanation
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)inAddingTotalBest regards,
Phillip | DeclutterData 🙋🏻♂️