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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.