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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Jtep
Regular Visitor

Cummulative Total with filter retained

Hello,

I trying to get a cumulative total working for profit and loss, very similar to that found at http://www.daxpatterns.com/cumulative-total/

My formula:

=
CALCULATE (
[Total Net Profit and Loss],
FILTER (
ALL ( TradeLog_Table ),
TradeLog_Table[Close Date] <= MAX ( TradeLog_Table[Close Date] )
)
)

This works, but it returns more rows than desired, because my ‘TradeLog_table’ has been filtered via a lookup table and I want that filtering to be respected for the above calculation.  Ie the ‘FILTER(ALL(TradeLog_Table) part naturally returns all rows but I only want rows returned that have been filtered via the lookup table filter (in my case a slicer on the lookup table).  I’ve tried ALLSELECTED but this still returns all rows.

 

Thanks

7 REPLIES 7
GilbertQ
Super User
Super User

Hi @Jtep

 

What happens if you remove the ALL filter?

 

My formula:
=
CALCULATE (
[Total Net Profit and Loss],
FILTER (TradeLog_Table ,
TradeLog_Table[Close Date] <= MAX ( TradeLog_Table[Close Date] )
)
)




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

Proud to be a Super User!







Power BI Blog

Thanks for quick reply!  With ALL removed as per your code, unwanted rows are removed (good), but the profit and loss does not aggregate, ie is not cummulative.   What is returned is the same as my '[Total Net Profit and Loss]' measure, a simple measure of SUM(TradeLog_table[Profit and Loss]).  The aggregation is only working on one row, with the date expression appearing to have no effect.

Hi there


Do you perhaps have a diagram of how the filtering is working. It appears as though the filtering is happening with the "Cross Filter Direction" set to both for another table. Which can always complicate things?





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

Proud to be a Super User!







Power BI Blog

Diagram attached.  A normal one to many relationship established.  Filtering is established by a slicer connected to my lookup table (table at the top).  This selects a particular broker, then the rows on the connected table below are filtered to show only rows with the selected broker(s).  Essentially I want a function like ALL that returns all 'currently filtered rows' opposed to 'all' rows'.

Untitled.png

Hi @Jtep

 

I would think that if you clicked on the Broker that it would then Filter the data to the Broker selected and then still show the cumulative total?

 

 





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

Proud to be a Super User!







Power BI Blog

If I attach the slicer to my data table the cummulative total works, but I need filtering controlled by the lookup table for other measures. 

 

I'm gonna have a break.  Cheers for the help.

So if you create a slicer on the data table it works?

But if you create a slicer off the TradeLog_Table it does not work?

Does the TradeLog_Table only have one entry per Broker?




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

Proud to be a Super User!







Power BI Blog

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

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.