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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
tom-lenzmeier
New Member

Custom Subtotal Labels In a Matrix

Hello,

 

I have a matrix for sales where I want to have custom labels for subtotals. I have a business, a product group, and the product. I have created a hierarchy and all the amounts are as expected. However, I can't seem to figure out how to get the subtotal line to display the business unit instead of just "total." For example

Business UnitGroupSales
  Unit AGroup 1$100
 Group 2$100
Unit A Total $200
   
Unit BGroup 3$100
 Group 4$100
Unit B Total $200
Total $400
1 ACCEPTED SOLUTION
Ritaf1983
Super User
Super User

Hi @tom-lenzmeier 

In a Power BI Matrix, you can only set one uniform label for subtotals . There’s no built-in way to display a different subtotal label for each group

Ritaf1983_0-1754676331902.png

If you need a different subtotal name per category, you can work around this by creating a “fake subtotal row” in your dimension table.

Steps:

Create a dimension table (e.g., Categories Matrix) with.

For example:

Ritaf1983_1-1754676536375.png

 

Bu (category)

Name (subcategory/product)

Extra rows for each category, such as “Total IT”, “Total Books”, “Total Clothes”.

Ritaf1983_2-1754676574785.png

Sort columns (Sort BU, SortName) to ensure the “Total …” row is always at the bottom of its group.

Ritaf1983_4-1754676969501.png

Create an inactive relationship between Categories Matrix[Name] and your fact table’s Name column.

Ritaf1983_5-1754677033510.png

Build a measure that:

Returns BLANK() if Bu is blank (avoids unwanted Matrix subtotal rows).

If Name contains “Total” → ignores the subcategory and sums at the category level.

Otherwise → activates the inactive relationship and sums at the subcategory level.

Sum for matrix :=
VAR IsTotalRow =
CONTAINSSTRING( UPPER( SELECTEDVALUE('Categories Matrix'[Name], "") ), "TOTAL" )

VAR Sum_ByBU =
CALCULATE(
SUM('Table'[Sales]),
REMOVEFILTERS('Categories Matrix'[Name]),
TREATAS( VALUES('Categories Matrix'[Bu]), 'Table'[Bu] )
)

VAR Sum_Detail_ByName =
CALCULATE(
SUM('Table'[Sales]),
USERELATIONSHIP('Table'[Name], 'Categories Matrix'[Name])
)

RETURN
IF(
ISBLANK( SELECTEDVALUE('Categories Matrix'[Bu]) ),
BLANK(),
IF( IsTotalRow, Sum_ByBU, Sum_Detail_ByName )
)

Now you can create a Matrix ( use the created table for rows of the matrix)
Note: You can’t bold the “Total …” label itself (it’s a regular row), but you can format the values using Conditional Formatting based on the IsTotalRow flag.

Ritaf1983_6-1754677265900.png

The pbix is attached

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

3 REPLIES 3
v-nmadadi-msft
Community Support
Community Support

Hi @tom-lenzmeier  ,
Thanks for reaching out to the Microsoft fabric community forum.

Try to create a hierarchy in your data,
Go to Model View.

Right click on Business Unit and click on create hierarchy

vnmadadimsft_0-1754887079599.png

 


Next in the properties panel

vnmadadimsft_1-1754887111083.png

 


add Product group and Product, them click on apply changes.
You would have create a business unit hierarchy with the above steps.

vnmadadimsft_2-1754887111084.png

 


Include that in your matrix and use sales as the values within it.

Here is the output

vnmadadimsft_3-1754887124277.png

 



Attaching the .pbix for reference.

I hope this information helps. Please do let us know if you have any further queries.
Thank you

Ritaf1983
Super User
Super User

Hi @tom-lenzmeier 

In a Power BI Matrix, you can only set one uniform label for subtotals . There’s no built-in way to display a different subtotal label for each group

Ritaf1983_0-1754676331902.png

If you need a different subtotal name per category, you can work around this by creating a “fake subtotal row” in your dimension table.

Steps:

Create a dimension table (e.g., Categories Matrix) with.

For example:

Ritaf1983_1-1754676536375.png

 

Bu (category)

Name (subcategory/product)

Extra rows for each category, such as “Total IT”, “Total Books”, “Total Clothes”.

Ritaf1983_2-1754676574785.png

Sort columns (Sort BU, SortName) to ensure the “Total …” row is always at the bottom of its group.

Ritaf1983_4-1754676969501.png

Create an inactive relationship between Categories Matrix[Name] and your fact table’s Name column.

Ritaf1983_5-1754677033510.png

Build a measure that:

Returns BLANK() if Bu is blank (avoids unwanted Matrix subtotal rows).

If Name contains “Total” → ignores the subcategory and sums at the category level.

Otherwise → activates the inactive relationship and sums at the subcategory level.

Sum for matrix :=
VAR IsTotalRow =
CONTAINSSTRING( UPPER( SELECTEDVALUE('Categories Matrix'[Name], "") ), "TOTAL" )

VAR Sum_ByBU =
CALCULATE(
SUM('Table'[Sales]),
REMOVEFILTERS('Categories Matrix'[Name]),
TREATAS( VALUES('Categories Matrix'[Bu]), 'Table'[Bu] )
)

VAR Sum_Detail_ByName =
CALCULATE(
SUM('Table'[Sales]),
USERELATIONSHIP('Table'[Name], 'Categories Matrix'[Name])
)

RETURN
IF(
ISBLANK( SELECTEDVALUE('Categories Matrix'[Bu]) ),
BLANK(),
IF( IsTotalRow, Sum_ByBU, Sum_Detail_ByName )
)

Now you can create a Matrix ( use the created table for rows of the matrix)
Note: You can’t bold the “Total …” label itself (it’s a regular row), but you can format the values using Conditional Formatting based on the IsTotalRow flag.

Ritaf1983_6-1754677265900.png

The pbix is attached

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
MFelix
Super User
Super User

Hi @tom-lenzmeier ,

 

You can customize the subtotal to be whatever value you want however that value is not dynamic you need to hardcode the value you need:

MFelix_0-1754667153498.png



So you are not able to do this type of customization.
You can add a custom field but it will not be aligned with the first column because it would be placed on the values part of the table.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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