Forum Discussion

fmasselink's avatar
fmasselink
Regular Visitor
4 years ago
Solved

Grouping & summarizing using column name lists

Hi,   I have a table (very simplified) with table headers that have a / (and my other columns also have some with a double-colon) (not sure how relevant that is with referencing the column/row) ...
  • User101's avatar
    4 years ago

    Perhaps you are looking for something like this:

       

    let

        Source = Sql.Databases("......"),

        AdventureWorksDW2019 = Source{[Name="AdventureWorksDW2019"]}[Data],

        dbo_DimProduct = AdventureWorksDW2019{[Schema="dbo",Item="DimProduct"]}[Data],

        #"Removed Columns" = Table.RemoveColumns(dbo_DimProduct,{"ProductKey", "ProductAlternateKey", "LargePhoto", "HebrewDescription", "ArabicDescription", "ChineseDescription", "TurkishDescription", "JapaneseDescription", "ThaiDescription", "GermanDescription", "FrenchDescription"}),

        allColumns = Table.ColumnNames(#"Removed Columns"),

        aggCols = {"ListPrice", "DealerPrice"},

        remaining = List.Difference(allColumns, aggCols),

        aggs = List.Transform(aggCols, (c) => {c, (t) => List.Sum(Table.Column(t, c)), type nullable number })

    in

       Table.Group(#"Removed Columns", "EnglishProductName", aggs)