Forum Discussion

dofrancis3's avatar
dofrancis3
Icon for Resolver I rankResolver I
1 year ago
Solved

SUMX in one colomn

Dear Team

I need your support i would to as per data set below i would like to have the results belown: (you cans use: SUMX or...)

 

Raw data

Val
0
0
1
0
1
1
0
1
1
1
1
  • lbendlin's avatar
    lbendlin
    1 year ago

    Group by val and add a sum aggregation

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlCK1YGRhhhsXCJwMhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Val = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Val", Int64.Type}}),
        #"Grouped Rows" = Table.Group(#"Changed Type", {"Val"}, {{"val", each List.Sum([Val]), type nullable text}}),
        #"Removed Other Columns" = Table.SelectColumns(#"Grouped Rows",{"val"})
    in
        #"Removed Other Columns"

    How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the entire Source step with your own source.

3 Replies

      • lbendlin's avatar
        lbendlin
        Icon for Super User rankSuper User

        Group by val and add a sum aggregation

         

        let
            Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlCK1YGRhhhsXCJwMhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Val = _t]),
            #"Changed Type" = Table.TransformColumnTypes(Source,{{"Val", Int64.Type}}),
            #"Grouped Rows" = Table.Group(#"Changed Type", {"Val"}, {{"val", each List.Sum([Val]), type nullable text}}),
            #"Removed Other Columns" = Table.SelectColumns(#"Grouped Rows",{"val"})
        in
            #"Removed Other Columns"

        How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the entire Source step with your own source.