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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Grizle
New Member

Can you add calculated columns to end of matrix?

Hi Everyone,

 

I have a matrix table and I want to add some calculated columns to the end of it. These are summary columns and should not appear under each of the current columns. 

 

Here is a basic example of what my data might look like:

DivisionSpecsValues
1sales500
1margin20%
1budget100
2sales400
2margin30%
2budget75
40sales1000
40margin15%
40budget99

 

FYI in my data there are many divisions (1000+) and specs (100+). I simplified the date example above. 

We have a series of filters allowing the user to select a more manageable amount of divisions and specs. 

 

I was able to add a total summary field using the built in total for a Matrix visual in Power BI. So our current matrix outputs similar to this:

Specs1240Total
Sales50040010001900
Margin20%30%15%65%
Budget1007599274

 

However we also want to add additional summary columns at the end (far right) of the matrix. Ideally we want something like this:

Specs1240TotalStd DevMean
Sales50040010001900321.46633.33
Margin20%30%15%65%7.64%21.67%
Budget100759927414.1591.33

 

I was able to build measures but if I add them to the values in my matrix they appear under each of the Divisions, and I don't want that. I need them setup as summary columns on the far right. 

 

Is a matrix table even capable of adding in these columns? Should I be doing this using a custom table in Dax?

Any tips, references, or advice would be greatly appreciated.

 

Thanks in advance!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Grizle 

You can use power query , put the following code in Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUSpOzEktBtKmBgZKsToQsdzEovTMPCDDyEAVLphUmpKeWgJkGEJVGiHpNkESg+s2huo2QtZtbgoWMzFA0g000QAhCtdvaKqKEIUbYGmpFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Division = _t, Specs = _t, Values = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Division", Int64.Type}, {"Specs", type text}, {"Values", type number}}),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Changed Type", {{"Division", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Changed Type", {{"Division", type text}}, "en-US")[Division]), "Division", "Values"),
    #"Added Custom" = Table.AddColumn(#"Pivoted Column", "Total", each [1]+[2]+[40]),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Mean", each [Total]/3)
in
    #"Added Custom1"

Output:

vxinruzhumsft_0-1671518250532.png

Best Regards!

Yolo Zhu

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

2 REPLIES 2
Anonymous
Not applicable

Hi @Grizle 

You can use power query , put the following code in Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUSpOzEktBtKmBgZKsToQsdzEovTMPCDDyEAVLphUmpKeWgJkGEJVGiHpNkESg+s2huo2QtZtbgoWMzFA0g000QAhCtdvaKqKEIUbYGmpFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Division = _t, Specs = _t, Values = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Division", Int64.Type}, {"Specs", type text}, {"Values", type number}}),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Changed Type", {{"Division", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Changed Type", {{"Division", type text}}, "en-US")[Division]), "Division", "Values"),
    #"Added Custom" = Table.AddColumn(#"Pivoted Column", "Total", each [1]+[2]+[40]),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Mean", each [Total]/3)
in
    #"Added Custom1"

Output:

vxinruzhumsft_0-1671518250532.png

Best Regards!

Yolo Zhu

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

FreemanZ
Super User
Super User

hi @Grizle 

 

This is not advisible, but still possibe.

 

Option1:

create multiple measures and plot with the measures instead of the columns

1 = 
CALCULATE(
    SUM(tbl1[Values]),
    tbl1[Division]=1
)
2 = 
CALCULATE(
    SUM(tbl1[Values]),
    tbl1[Division]=2
)
40 = 
CALCULATE(
    SUM(tbl1[Values]),
    tbl1[Division]=40
)
Total = SUM(tbl1[Values])

FreemanZ_0-1671343302069.png

 

Option2: pivot the Division column in Power Query, then add the total column with this:

Total2 = [1]+[2]+[40]  //with DAX or in PQ

you will get this:

FreemanZ_1-1671343418928.png

 

Considering the 1000+ division you have. none of them is advisible. Try to decompose the table and plot in separate visuals. 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors