Forum Discussion

mtomova's avatar
mtomova
Helper III
3 years ago
Solved

Power Query Group by aggregation with dynamic column names

Hi all,   I am trying to perform a group by in Power Query, which works fine if I use the interface. However, I am aggregating by certain columns, but in the future there will be more columns adde...
  • ImkeF's avatar
    3 years ago

    Hello mtomova ,
    you can use this formula for it:

    Table.Group(Custom1, {"UPRN"}, List.Transform(List.Difference(Table.ColumnNames(#"Changed Type"), {"UPRN"}), (l)=> {l, each List.Sum(Table.Column(_, l)), type nullable number}))

    This will add any field from your table that is not called "UPRN" as an aggregated field dynamically.