Forum Discussion

AnonymeC's avatar
AnonymeC
Regular Visitor
1 year ago
Solved

[Help needed] Group by several columns without selecting individually 1 by 1

Hi everyone,   My aim is very simple yet somehow I couldn't find the ressources to do this task, I was hoping you could help me.   So my goal is to do a simple group by for all the columns in my ...
  • slorin's avatar
    1 year ago

    Hi AnonymeC 

     

    let
    Source = YourSource,
    UnPivot = Table.UnpivotOtherColumns(Source, {"Code"}, "Attribute", "Value"),
    Pivot = Table.Pivot(UnPivot, List.Distinct(UnPivot[Attribute]), "Attribute", "Value", List.Sum)
    in
    Pivot

    or

    let
    Source = YourSource,
    Group = Table.Group(Source, {"Code"},
    List.Transform(
    List.Skip(Table.ColumnNames(Source)),
    each {_, Expression.Evaluate("each List.Sum(["& _ &"])", #shared), type number } ) )
    in
    Group 

    Stéphane