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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

How to filter a Matrix Visual based on a Cumulative Sum

Hi all, I have a table of data like this called 'Stock':

IDItemDateSiteTypeQuantity
Inventory100370609/14/20WARM1Inventory14,636
3010209974100370609/14/20WARM1Sales Order-10,000
100017032100370609/23/20WARM1Production Orders49,000
3010210118100370609/14/20WARM1Sales Order1,000
3010210277100370609/15/20WARM1Sales Order1,500
3010210355100370609/15/20WARM1Sales Order12,000

 

And a measure to calculate the cumulative sum of this data:

Quantity running total in Date =
CALCULATE(
    SUM(Stock[Quantity]),
    FILTER(
        ALLSELECTED(Stock[Date]),
        ISONORAFTER(Stock[Date], MAX(Stock[Date]), DESC)
    )
)
)

 

Which is loaded into a matrix table like this:

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

CONTINUED

loaded into a table like this:
Capture.PNG

 

I'd like to filter this matrix to only show items where the cumulative sum TOTAL is <0.  I've tried filtering by where the Cumulative Sum measure is <0, but this filters the table to only calculate on transactions where the quantity is <0.  Does anyone know how to do this?

View solution in original post

Hi @Anonymous ,

 

There should be no problem with the method, but the order of the conditions is reversed.

Quantity running total in Date =
var _cumm =
CALCULATE(
SUM(Stock[Quantity]),
FILTER(
ALLSELECTED(Stock[Date]),
ISONORAFTER(Stock[Date], MAX(Stock[Date]), DESC)
)
)
)

return IF(_cumm<0,BLANK(),_cumm))

 

Best Regards,
Liang
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

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous ,

Try like

Quantity running total in Date =
var _cumm =
CALCULATE(
SUM(Stock[Quantity]),
FILTER(
ALLSELECTED(Stock[Date]),
ISONORAFTER(Stock[Date], MAX(Stock[Date]), DESC)
)
)
)

return if(_cumm <=0 , then _cumm else blank())

 

If it works if may have some impact on the grand total so switch formula based on isfiltered or hasonevalue

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak, thank you for the reply, but this formula doesn't seem to get the result I'm looking for.  Using this formula, now the table only shows the days with a negative cumulative value and the Total has disappeared from the visual:

garynorcross_0-1600175845806.png

Do you have any other ideas on how to achieve this?

Hi @Anonymous ,

 

There should be no problem with the method, but the order of the conditions is reversed.

Quantity running total in Date =
var _cumm =
CALCULATE(
SUM(Stock[Quantity]),
FILTER(
ALLSELECTED(Stock[Date]),
ISONORAFTER(Stock[Date], MAX(Stock[Date]), DESC)
)
)
)

return IF(_cumm<0,BLANK(),_cumm))

 

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

Anonymous
Not applicable

CONTINUED

loaded into a table like this:
Capture.PNG

 

I'd like to filter this matrix to only show items where the cumulative sum TOTAL is <0.  I've tried filtering by where the Cumulative Sum measure is <0, but this filters the table to only calculate on transactions where the quantity is <0.  Does anyone know how to do this?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.