To calculate a running total in DAX, we usually use a combination of CALCULATE, FILTER, and ALL (or sometimes DATESYTD for date-based calculations). The idea is to sum up all values from the beginning up to the current point in the selected context — like a cumulative total.
For example, suppose I have a Sales table with columns Date and Amount. A simple running total measure would be:
Running Total =
CALCULATE(
SUM(Sales[Amount]),
FILTER(
ALL(Sales[Date]),
Sales[Date] <= MAX(Sales[Date])
)
)
Here’s how it works:
SUM(Sales[Amount])adds up all sales amounts.FILTER(ALL(Sales[Date]), Sales[Date] <= MAX(Sales[Date]))modifies the filter context so that DAX includes all dates up to and including the current date.CALCULATEthen applies that modified context to compute the cumulative sum.
In one of my projects, I used this pattern to show cumulative sales progress in a Power BI line chart. It helped visualize how sales were growing month over month throughout the year.
If the dataset uses a proper Date table, I sometimes prefer the built-in time intelligence function:
Running Total (YTD) =
TOTALYTD(SUM(Sales[Amount]), 'Date'[Date])
This function automatically handles the year-to-date logic and resets at the start of a new year, which is very handy for financial reporting.
One challenge I faced was when the date column wasn’t continuous — missing dates caused gaps in the running total. I fixed it by ensuring the model had a complete Date table marked as a “Date Table” in Power BI.
As an alternative, when I need a running total by another category (like customer or product), I adjust the filter condition to include those dimensions — for instance:
CALCULATE(
SUM(Sales[Amount]),
FILTER(
ALL(Sales),
Sales[CustomerID] = MAX(Sales[CustomerID]) &&
Sales[Date] <= MAX(Sales[Date])
)
)
So in short — a running total in DAX is achieved by summing values over time using CALCULATE + FILTER + ALL, and for date-based scenarios, TOTALYTD is a cleaner, optimized alternative.
