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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
PBIRookieAZ
Regular Visitor

Adding calculation as rows in Matrix

PBIRookieAZ_0-1744065413349.png

Hi PBI Expoerts, 

I have the table in blue box as a matrix visual in PBI. I need to add two rows for GP and GM% calculations at the bottom of the matrix. How can I do that? TIA!!

1 ACCEPTED SOLUTION
v-dineshya
Community Support
Community Support

Hi @PBIRookieAZ ,

Thanks for reaching out to the Microsoft fabric community forum. 

 

Solution 1: Using DAX Measures

Create Measures for GP and GM%: Go to the Modeling tab & Click on New Measure.

DAX formulas:

Gross Profit (GP): GP = SUM('Sales'[Revenue]) - SUM('Sales'[Cost of Goods Sold])

Gross Margin % (GM%): GM% = DIVIDE([GP], SUM('Sales'[Revenue]), 0)

Add Measures to the Matrix: In your matrix visual, drag the GP and GM% measures into the Values field.

Show as Total Row: In the matrix settings, under Format → Subtotals, ensure that subtotals are enabled if needed.

 

Solution 2: Create a Calculated Table:

Summary Table =
UNION (
SELECTCOLUMNS('Sales', "Category", 'Sales'[Category], "Value", [GP]),
SELECTCOLUMNS('Sales', "Category", "GM%", "Value", [GM%])
)

Alternative code:

SummaryTable =
UNION(
SUMMARIZE(
'Sales',
'Sales'[Category],
"GP", [GP],
"GM%", [GM%]
),
ROW(
"Category", "Total",
"GP", [GP],
"GM%", [GM%]
)
)

Add the Custom Table to the Matrix Visual: Replace your original table with the SummaryTable in the matrix visual. This table will include the GP and GM% calculations at the bottom.

Format the Matrix Visual: Adjust the formatting of the matrix visual to ensure that the new rows for GP and GM% are clearly visible and distinguishable from the other rows.

 

If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS. Feel free to reach out if you need further assistance.
Thanks and Regards

View solution in original post

5 REPLIES 5
v-dineshya
Community Support
Community Support

Hi @PBIRookieAZ ,

Thanks for reaching out to the Microsoft fabric community forum. 

 

Solution 1: Using DAX Measures

Create Measures for GP and GM%: Go to the Modeling tab & Click on New Measure.

DAX formulas:

Gross Profit (GP): GP = SUM('Sales'[Revenue]) - SUM('Sales'[Cost of Goods Sold])

Gross Margin % (GM%): GM% = DIVIDE([GP], SUM('Sales'[Revenue]), 0)

Add Measures to the Matrix: In your matrix visual, drag the GP and GM% measures into the Values field.

Show as Total Row: In the matrix settings, under Format → Subtotals, ensure that subtotals are enabled if needed.

 

Solution 2: Create a Calculated Table:

Summary Table =
UNION (
SELECTCOLUMNS('Sales', "Category", 'Sales'[Category], "Value", [GP]),
SELECTCOLUMNS('Sales', "Category", "GM%", "Value", [GM%])
)

Alternative code:

SummaryTable =
UNION(
SUMMARIZE(
'Sales',
'Sales'[Category],
"GP", [GP],
"GM%", [GM%]
),
ROW(
"Category", "Total",
"GP", [GP],
"GM%", [GM%]
)
)

Add the Custom Table to the Matrix Visual: Replace your original table with the SummaryTable in the matrix visual. This table will include the GP and GM% calculations at the bottom.

Format the Matrix Visual: Adjust the formatting of the matrix visual to ensure that the new rows for GP and GM% are clearly visible and distinguishable from the other rows.

 

If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS. Feel free to reach out if you need further assistance.
Thanks and Regards

Hi @PBIRookieAZ ,

If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS. Feel free to reach out if you need further assistance.
Thanks and Regards

Hi @PBIRookieAZ ,

If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS. Feel free to reach out if you need further assistance.
Thanks and Regards

Hi @PBIRookieAZ ,

If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS. Feel free to reach out if you need further assistance.
Thanks and Regards

lbendlin
Super User
Super User

You can't really do that unless you go full custom matrix.  Better to use a separate visual as you are doing.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.