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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
lost_flower
Helper III
Helper III

subtotal in matrix table

Hi,

is it possible in the visualisation with a matrix table to insert a subtotal under a specific row? For example

the matrix table shows that

 

lost_flower_4-1706778591942.png

 

 

but I need this

lost_flower_5-1706778602612.png

 

 

Thanks for any ideas

 

1 ACCEPTED SOLUTION
123abc
Community Champion
Community Champion

In Power BI, you can use DAX (Data Analysis Expressions) to calculate subtotals in a matrix table. However, Power BI does not directly support inserting subtotals under specific rows in a matrix table like the Excel pivot table.

To achieve subtotaling under specific rows in a matrix table in Power BI, you can create calculated measures using DAX. Here's a general approach:

  1. Define a measure for the subtotal: Create a DAX measure that calculates the subtotal based on the rows you want to subtotal.

  2. Modify the matrix table: Add the subtotal measure to the matrix table and place it in the appropriate position.

Here's a basic example of how you can create a subtotal measure in DAX:

 

Subtotal Measure =
VAR SelectedRows = VALUES('YourTableName'[RowField]) // Identify the rows you want to subtotal
RETURN
CALCULATE(
[YourExistingMeasure], // Your existing measure to subtotal
FILTER(
ALL('YourTableName'[RowField]), // All rows from the row field
'YourTableName'[RowField] IN SelectedRows // Filter rows for subtotal
)
)

 

Replace 'YourTableName' with the name of your table and [RowField] with the column you are using to define rows in your matrix table. Also, replace [YourExistingMeasure] with the measure you want to subtotal.

For example, if you want to subtotal under the "Region" row in your matrix table, you can create a measure like this:

 

Region Subtotal =
VAR SelectedRegions = VALUES('YourTableName'[Region])
RETURN
CALCULATE(
[Total Sales], // Assuming 'Total Sales' is your existing measure
FILTER(
ALL('YourTableName'[Region]), // All regions
'YourTableName'[Region] IN SelectedRegions // Filter regions for subtotal
)
)

 

Then you can add this measure to your matrix table in Power BI and place it under the "Region" row.

This approach allows you to calculate subtotals under specific rows in a matrix table in Power BI using DAX measures.

 

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

 

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

View solution in original post

3 REPLIES 3
lost_flower
Helper III
Helper III

I found the solution by chance. create the subtotal with New Group. 

 

lost_flower_0-1706796503107.png

 

thanks for the impulse 😇

 

123abc
Community Champion
Community Champion

In Power BI, you can use DAX (Data Analysis Expressions) to calculate subtotals in a matrix table. However, Power BI does not directly support inserting subtotals under specific rows in a matrix table like the Excel pivot table.

To achieve subtotaling under specific rows in a matrix table in Power BI, you can create calculated measures using DAX. Here's a general approach:

  1. Define a measure for the subtotal: Create a DAX measure that calculates the subtotal based on the rows you want to subtotal.

  2. Modify the matrix table: Add the subtotal measure to the matrix table and place it in the appropriate position.

Here's a basic example of how you can create a subtotal measure in DAX:

 

Subtotal Measure =
VAR SelectedRows = VALUES('YourTableName'[RowField]) // Identify the rows you want to subtotal
RETURN
CALCULATE(
[YourExistingMeasure], // Your existing measure to subtotal
FILTER(
ALL('YourTableName'[RowField]), // All rows from the row field
'YourTableName'[RowField] IN SelectedRows // Filter rows for subtotal
)
)

 

Replace 'YourTableName' with the name of your table and [RowField] with the column you are using to define rows in your matrix table. Also, replace [YourExistingMeasure] with the measure you want to subtotal.

For example, if you want to subtotal under the "Region" row in your matrix table, you can create a measure like this:

 

Region Subtotal =
VAR SelectedRegions = VALUES('YourTableName'[Region])
RETURN
CALCULATE(
[Total Sales], // Assuming 'Total Sales' is your existing measure
FILTER(
ALL('YourTableName'[Region]), // All regions
'YourTableName'[Region] IN SelectedRegions // Filter regions for subtotal
)
)

 

Then you can add this measure to your matrix table in Power BI and place it under the "Region" row.

This approach allows you to calculate subtotals under specific rows in a matrix table in Power BI using DAX measures.

 

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

 

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

Hi, thanks for your help 😊

 

I have successfully created the subtotal according your example. But I can only display it in the matrix table under Values instead of Rows. I need the subtotal in Rows. There is no possibility, is there?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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