Forum Discussion

Mic1979's avatar
Mic1979
Post Partisan
1 year ago
Solved

Group Based on Column Name

Hello all,   I habe a table where I need to Table.Group function, and I would like to make it based on some character present in the column name.   Here what I did so far. I defined the following...
  • Mic1979's avatar
    Mic1979
    1 year ago

    Hello

     

    thanks for your suggestions.

     

    Finally, I found this solution:

     

    Header = Table.ColumnNames (#"Removed Columns2"),
    SelectDollarColumns = List.Select(Table.ColumnNames(#"Removed Columns2"), each Text.Contains(_, "$")),
    HeadersToRemove = List.Combine ({{"PHASE IN TOTAL MATURE VOLUMES"},SelectDollarColumns}),
    HeaderDifference = List.Difference (Header,HeadersToRemove),

    Grouped_Table = Table.Group (
    #"Removed Columns2",
    HeaderDifference,
    List.Transform(
    SelectDollarColumns,
    (l)=> {l, each List.Sum(Table.Column(_, l)), type nullable number}
    )
    )