Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
dofrancis3
Helper III
Helper III

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...)

dofrancis3_0-1732284039045.png

 

Raw data

Val
0
0
1
0
1
1
0
1
1
1
1
1 ACCEPTED SOLUTION

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.

View solution in original post

3 REPLIES 3
Prasanthke
New Member

please explain your question clearly

@FreemanZ , @Jihwan_Kim , @lbendlin@Prasanthke , @shafiz_p  ibendlin In my data set i have this colomn:

dofrancis3_1-1732290211670.png

 

So i need to have the result below  (table):

dofrancis3_2-1732290276009.png

How can i do it?

 

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.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.