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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Yoshimitsu411
Resolver I
Resolver I

SUMX Multiple Columns Then Store Output in Another Table

Hello All

 

Thank you in advance for any assistance.

 

I would like to SUMX the values stored in multiple columns and store the output in a separate table to be used in a bar chart.

 

Main table:

 

FruitMonthly.PNG

 

I want to output the total of each column (except Item column) to a table like this:

 

FruitMonthlyActuals.PNG

 

So for Jan the value should be 15, Feb will be 5, Mar will be 2 and so on. I'm not sure if I can use Pivot or Unpivot as there are other columns in the main table (not shown in the screenshot).

 

Result to look similar to this.

 

FruitMonthlyBarChart.PNG

 

Alternatively if there is a way to do this without creating a separate table please let me know.

 

Thank you.

 

Yoshi

1 ACCEPTED SOLUTION
dax
Community Support
Community Support

Hi Yoshimitsu41,

You could try below M code to see whether it work or not

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTIEYmMgNgdiIzA/VidaKQkqAxIxg7NBMslAlimSqAlYf2wsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [name = _t, #"Jan 2019" = _t, #"Feb 2019" = _t, #"Mar 2019" = _t, #"Apr 2019" = _t, #"May 2019" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"name", type text}, {"Jan 2019", Int64.Type}, {"Feb 2019", Int64.Type}, {"Mar 2019", Int64.Type}, {"Apr 2019", Int64.Type}, {"May 2019", Int64.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"name"}, "Attribute", "Value"),
    #"Grouped Rows" = Table.Group(#"Unpivoted Columns", {"Attribute"}, {{"sum", each List.Sum([Value]), type number}})
in
    #"Grouped Rows"

 

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
dax
Community Support
Community Support

Hi Yoshimitsu41,

You could try below M code to see whether it work or not

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTIEYmMgNgdiIzA/VidaKQkqAxIxg7NBMslAlimSqAlYf2wsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [name = _t, #"Jan 2019" = _t, #"Feb 2019" = _t, #"Mar 2019" = _t, #"Apr 2019" = _t, #"May 2019" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"name", type text}, {"Jan 2019", Int64.Type}, {"Feb 2019", Int64.Type}, {"Mar 2019", Int64.Type}, {"Apr 2019", Int64.Type}, {"May 2019", Int64.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"name"}, "Attribute", "Value"),
    #"Grouped Rows" = Table.Group(#"Unpivoted Columns", {"Attribute"}, {{"sum", each List.Sum([Value]), type number}})
in
    #"Grouped Rows"

 

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors