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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Table.Group possible to group except certain columns?

Hi all, 

 

I am sorry if this is a question asked before, but I can't find it. 

 

I use a Table.Group function in Power Query to group my table on three summarizations. But the table I am extracting from gets new attributes on a regular basis. Now I have to manual add these columns to the first part of the Table.Group function. 

 

Is there a possibility to add something like a Table.Group except the summarizations Lists? So when a new column gets added to the table in the datamart, and my dataset is refreshed, I don't have to add this manually?

 

Thanks!

1 ACCEPTED SOLUTION
Jakinta
Solution Sage
Solution Sage

Cols = Table.ColumnNames(PreviousStep)
SumCols = {"Sum1","Sum2","Sum3"} // hardcoded or apply some filter to Cols list
GroupCols = List.Difference(Cols, SumCols)
Group = Table.Group ( PreviousStep, GroupCols, List.Transform ( SumCols, (Col)=> {Col, each List.Sum(_[Col]), type number}) )

View solution in original post

2 REPLIES 2
Jakinta
Solution Sage
Solution Sage

Cols = Table.ColumnNames(PreviousStep)
SumCols = {"Sum1","Sum2","Sum3"} // hardcoded or apply some filter to Cols list
GroupCols = List.Difference(Cols, SumCols)
Group = Table.Group ( PreviousStep, GroupCols, List.Transform ( SumCols, (Col)=> {Col, each List.Sum(_[Col]), type number}) )
Anonymous
Not applicable

Hi, thanks for this reaction. 

 

unfortunately, I run into an error:

 

Expression.Error: The column '_Col' of the table wasn't found. Details: _Col

 

I am not sure what is going wrong here, Col should not be a column but should represent the columns in SumCols of course..

 

--edit--

If I replace the List.Transform part with the individual Sum expressions (so I use the columns instead of the list), it works.. 

 

Thanks for the first part anyway, this was the most needed!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors