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
MrMP
Helper III
Helper III

Subtotal based on measure

Hi all,

 

I have table:

 

KeyQuantityMeasureMeasure2
AA500
AA12130 (12+8+10)
AA8130 (12+8+10)
AA10130 (12+8+10)
BB313

 

How is it possible to get subtotal based on Measure, so that in Measure2 I have subtotal of Key AA and not summing where measure is 0.

 

Thank you all for support so far, this is such a great community!

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

Hi @MrMP ,

 

The method of nesting measures may cause calculation logic errors. I suggest replacing the measure with a calculate column, and then creating a measure to get the sum value corresponding to column 1.

M =
CALCULATE (
    SUM ( 'Table'[Quantity] ),
    FILTER ( ALL ( 'Table' ), 'Table'[calculated column] = 1 )
)


If the problem is still not resolved, please provide detailed error information . Let me know immediately, looking forward to your reply.

Best Regards,
Henry

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

5 REPLIES 5
v-henryk-mstf
Community Support
Community Support

Hi @MrMP ,

 

The method of nesting measures may cause calculation logic errors. I suggest replacing the measure with a calculate column, and then creating a measure to get the sum value corresponding to column 1.

M =
CALCULATE (
    SUM ( 'Table'[Quantity] ),
    FILTER ( ALL ( 'Table' ), 'Table'[calculated column] = 1 )
)


If the problem is still not resolved, please provide detailed error information . Let me know immediately, looking forward to your reply.

Best Regards,
Henry

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

mahoneypat
Microsoft Employee
Microsoft Employee

Please try this measure expression.  Replace Qty and Measure1 with your actual table and measure names.

 

Exclude Zeros =
VAR vSummary =
    CALCULATETABLE (
        ADDCOLUMNS (
            SUMMARIZE ( Qty, Qty[Key], Qty[Quantity] ),
            "cMeasure1", [Measure1]
        ),
        ALLEXCEPT ( Qty, Qty[Key] )
    )
VAR vResult =
    SUMX ( FILTER ( vSummary, [cMeasure1] > 0 ), Qty[Quantity] )
RETURN
    IF ( [Measure1] = 00vResult )

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thank you for the solution. But for some reason I couldnt use it since I ran out of memory.

mahoneypat
Microsoft Employee
Microsoft Employee

Please confirm you used it as a measure and not a column.  Also, can you share more about your model (tables, # rows, relationships, etc.) and the expression you tried?

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Yes I did use it as measure. Well the whole pbix is really complex. Probably has 100+ measures, # of rows is ~40k, 80 pages. There are only few relationships and they are just small master tables.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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