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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Create Subtotal in Matrix

Hi All -

 

What is the best way to create a subtotal in a Matrix?

 

The final table should look like the following.  Basically, the question is how to get the subtotal "R+N". 

 

StatusSalesProfit %
E100010.0%
R2008.0%
N2007.0%
R+N3007.5%

 

The usual Matrix total gives E+R+N, but I only want to subtotal of R+N.

 

Thank you, Mark

2 ACCEPTED SOLUTIONS
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

If your data structure as below

Status Sales Profit %
E 1000 10.0%
R 200 8.0%
N 200 7.0%


create measures

Measure_Sales =IF (
    HASONEVALUE ( Sheet10[Status] ),
    SUM ( Sheet10[Sales] ),
    CALCULATE (
        SUM ( Sheet10[Sales] ),
        FILTER ( ALL ( Sheet10 ), [Status] IN { "R", "N" } )
    )
)


Measure_Profit % =
IF (
    HASONEVALUE ( Sheet10[Status] ),
    SUM ( Sheet10[Profit %] ),
    CALCULATE (
        AVERAGE ( Sheet10[Profit %] ),
        FILTER ( ALL ( Sheet10 ), [Status] IN { "R", "N" } )
    )
)

11.png

 

 

Best Regards

Maggie

 

Community Support Team _ Maggie Li
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

Anonymous
Not applicable

Thank you Maggie ... that worked!

 

One thing that I can't get to work is to rename the "Total" in the matrix to "N + R".

 

Also I included some code below (for the next person I suppose) to shows how I applied the formula you provided ...

 

ECR_RN_Subtotal = 
IF (
    HASONEVALUE ( Sheet1[Contract_Status]),
    [WECR],
    CALCULATE (
        [WECR],
        FILTER ( ALL ( Sheet1 ), [Contract_Status] IN { "Renewal", "New" } )
    )
)

WECR = DIVIDE(SUMX(Sheet1, Key_Measures[EP] * Key_Measures[ECR]), Key_Measures[EP])

EP = SUM(Sheet1[EP])

ERC = SUM(Sheet1[ERC])

View solution in original post

3 REPLIES 3
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

If your data structure as below

Status Sales Profit %
E 1000 10.0%
R 200 8.0%
N 200 7.0%


create measures

Measure_Sales =IF (
    HASONEVALUE ( Sheet10[Status] ),
    SUM ( Sheet10[Sales] ),
    CALCULATE (
        SUM ( Sheet10[Sales] ),
        FILTER ( ALL ( Sheet10 ), [Status] IN { "R", "N" } )
    )
)


Measure_Profit % =
IF (
    HASONEVALUE ( Sheet10[Status] ),
    SUM ( Sheet10[Profit %] ),
    CALCULATE (
        AVERAGE ( Sheet10[Profit %] ),
        FILTER ( ALL ( Sheet10 ), [Status] IN { "R", "N" } )
    )
)

11.png

 

 

Best Regards

Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you Maggie ... that worked!

 

One thing that I can't get to work is to rename the "Total" in the matrix to "N + R".

 

Also I included some code below (for the next person I suppose) to shows how I applied the formula you provided ...

 

ECR_RN_Subtotal = 
IF (
    HASONEVALUE ( Sheet1[Contract_Status]),
    [WECR],
    CALCULATE (
        [WECR],
        FILTER ( ALL ( Sheet1 ), [Contract_Status] IN { "Renewal", "New" } )
    )
)

WECR = DIVIDE(SUMX(Sheet1, Key_Measures[EP] * Key_Measures[ECR]), Key_Measures[EP])

EP = SUM(Sheet1[EP])

ERC = SUM(Sheet1[ERC])
Anonymous
Not applicable

Please note that there was a slight error in the above table.  The R+N sales total should be $400 (not $300).

 

Corrected table:

 

StatusSalesProfit %
E100010.0%
R2008.0%
N2007.0%
R+N4007.5%

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.