Forum Discussion
Anonymous
5 years agoNot 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 extract...
- 5 years ago
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}) )
Jakinta
5 years agoSolution 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}) )- Anonymous5 years agoNot 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!