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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
dax_newbie
Frequent Visitor

Explanation of Cumulative total DAX formula

Hi Community,

 

I was going through the DAX formula for cumulative/running total in this link:

https://community.powerbi.com/t5/Desktop/Cumulative-Total/td-p/43115 

 

 

Running Total MEASURE = 
CALCULATE (
    SUM ( 'All Web Site Data (2)'[UniquePageviews] ),
    FILTER (
        ALL ( 'All Web Site Data (2)' ),
        'All Web Site Data (2)'[Date] <= MAX ( 'All Web Site Data (2)'[Date] )
    )
)

 

 

I couldn't understand one thing in the above formula. How does the MAX bring the value that is present in the current filter context. I understand that using ALL clears any filters and the FILTER iterates through the table for each row. But one thing I don't get is how the MAX bring the value that is currently present in the filter context. 

 

Please help with this explanation!

1 ACCEPTED SOLUTION

Running Total MEASURE = 
CALCULATE (
    SUM ( 'All Web Site Data (2)'[UniquePageviews] ),
    FILTER (
        ALL ( 'All Web Site Data (2)' ),  //Clear filter in table
        'All Web Site Data (2)'[Date] <= MAX ( 'All Web Site Data (2)'[Date] ) //Filter date is less than or equal to the date of the current row.
    )
)

Sum the values, use the all function to clear the filter in the table, and calculate the sum of dates less than or equal to the current row in each row.

View solution in original post

3 REPLIES 3
mahoneypat
Microsoft Employee
Microsoft Employee

Please see if this article clarifies things.

Filter Arguments in CALCULATE - SQLBI

 

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


Hi Pat,

 

The article is for normal '=' filters which I am able to understand , but this filter with MAX alone is where I am stuck. I couldn't get how MAX value brings the current row's value. I am hoping to understand this so that I can better understand FILTER within CALCUALTE.

Running Total MEASURE = 
CALCULATE (
    SUM ( 'All Web Site Data (2)'[UniquePageviews] ),
    FILTER (
        ALL ( 'All Web Site Data (2)' ),  //Clear filter in table
        'All Web Site Data (2)'[Date] <= MAX ( 'All Web Site Data (2)'[Date] ) //Filter date is less than or equal to the date of the current row.
    )
)

Sum the values, use the all function to clear the filter in the table, and calculate the sum of dates less than or equal to the current row in each row.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.