Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
rhenus-florian
New Member

Dynamic Table.Group with dynamic amount of Columns

Hello,

 

First, I want to excuse my bad English, nevertheless i hope you can understand my problem. 

I want to group with sum agregation several columns of a table - with the Table.Group function. My problem is I dont have a fix list of columns. The number of columns is variable (can be 1,2,3,.... columns).

 

My start/source table is called table1.

rhenusflorian_1-1664445511785.png

My List which includes all columns I want to group is called List1.

rhenusflorian_2-1664445643414.png

I cant find a solution for my problem, most times it is an error.

        Table.Group(table1, {"RepeatGroup"},.... 

I dont know what  the last part of the function is.  

 

I hope someone can help me. My further questions please ask.

 

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

=Table.Group(Table1,"RepeatGroup",List.Transform(List1,each {_,(x)=>List.Sum(Table.Column(x,_))}))

View solution in original post

2 REPLIES 2
wdx223_Daniel
Super User
Super User

=Table.Group(Table1,"RepeatGroup",List.Transform(List1,each {_,(x)=>List.Sum(Table.Column(x,_))}))

Daryl-Lynch-Bzy
Resident Rockstar
Resident Rockstar

Hi @rhenus-florian - thank you for your question.  I could follow what you are asking. 

 

I would like to suggest using the Unpivot Other Columns feature in Power BI before Grouping.  The approach will lead to Group By including "RepeatGroup, Attribute, Value".   Table.UnpivotOtherColumns - PowerQuery M | Microsoft Learn.  The Attribute column will dynamically change for the new columns.

 

After using Group By, you can alway Pivot back to have the columns, but this may not be necessary.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.