Cumulative measures break the moment a slicer gets added — unless you understand exactly how ALLSELECTED, FILTER, and CALCULATE interact. This lesson builds accurate, production-ready cumulative sum, minimum, and maximum measures from first principles, so you can fix them when they break and build them right the first time.

Here's a scenario that every Power BI developer runs into eventually: your sales manager wants a report showing cumulative revenue by month — the classic "how much have we sold so far this year" chart. You build what seems like an obvious measure, drop it on a line chart, and it looks perfect. Then a slicer gets added. Someone filters by region. The cumulative total breaks in ways that feel impossible to explain. The numbers don't add up. The chart goes flat. Or worse, the running total suddenly resets in the middle of the year for no visible reason.
Cumulative totals are deceptively tricky in DAX because they require you to think about two filter contexts simultaneously: the current visual context (which row or column you're on) and the expanded context that defines "everything up to this point." When you add dynamic slicers, cross-filters, and hierarchies into the mix, that tension becomes a genuine engineering challenge. The measures that work beautifully in a simple table often behave unpredictably the moment a user starts interacting with the report.
By the end of this lesson, you'll be able to build robust cumulative sum, minimum, and maximum measures that survive real-world filter interactions, work correctly across both date hierarchies and categorical dimensions, and perform efficiently enough for production use. This isn't a lesson about TOTALYTD (we'll mention it, but it's a narrow solution). This is about understanding the underlying pattern so you can apply it to any scenario you encounter.
What you'll learn:
FILTER + ALL is the foundation of cumulative calculations and how to choose the right variantMINX beats MIN in this contextYou should be comfortable with the core CALCULATE and filter context mechanics covered in Master DAX CALCULATE and Filter Context in Power BI. You should also understand the difference between row context and filter context — if that distinction still feels fuzzy, Row Context vs Filter Context: The Mental Model Every DAX User Needs will give you the foundation you need before continuing.
A working knowledge of iterator functions like SUMX and MAXX is assumed. If you want a quick refresher, DAX Iterators Explained: How SUMX, AVERAGEX, and MAXX Evaluate Row by Row has you covered.
Before writing a single line of code, let's be precise about what a cumulative measure needs to do. When a visual places your measure at the row for "March 2024," you need the measure to:
Steps 2 and 3 are where DAX's CALCULATE and FILTER/ALL combination does the heavy lifting. The challenge is in step 4: you want to remove the date filter (so you can expand it), while keeping every other filter in place.
This is why ALL('Date') is too aggressive for most real-world reports. It strips everything off the date table — including filters you actually want to keep, like a fiscal year slicer. And ALLSELECTED('Date') fixes one problem but introduces subtle bugs of its own when used carelessly.
We'll work through each variant deliberately so you understand when to reach for each one.
For this lesson, we'll use a retail sales scenario. The model has:
OrderDate, ProductKey, RegionKey, Revenue, Quantity, UnitCostDate, Year, MonthNumber, MonthName, Quarter, FiscalYear, FiscalMonthNumberProductKey, Category, SubcategoryRegionKey, RegionName, CountryThe Date table is marked as a Date table in Power BI, and all relationships are standard one-to-many from the dimension to the fact table.
Our base measure is simple:
Total Revenue =
SUM( Sales[Revenue] )
Everything we build will be a measure, not a calculated column — cumulative logic belongs in measures because it needs to respond dynamically to filter context.
Note
If you're wondering why we're using measures rather than calculated columns here, the answer is that calculated columns evaluate at data refresh time in a fixed row context, while measures evaluate at query time in whatever filter context the visual creates. Cumulative logic depends entirely on knowing what date you're "currently at," which only exists at query time. See DAX Fundamentals: When to Use Calculated Columns vs Measures in Power BI for a full breakdown.
Let's build the first version and understand exactly why it's written the way it is:
Cumulative Revenue v1 =
VAR CurrentDate = MAX( 'Date'[Date] )
RETURN
CALCULATE(
[Total Revenue],
FILTER(
ALL( 'Date' ),
'Date'[Date] <= CurrentDate
)
)
Walk through the logic:
MAX('Date'[Date]) captures the latest date in the current filter context. If the visual is showing a row for March 2024, and the Date table is filtered to March 2024 dates, MAX returns March 31, 2024.ALL('Date') removes the existing filter from the Date table entirely, giving FILTER a clean set of all dates to work with.FILTER(..., 'Date'[Date] <= CurrentDate) then reconstructs a new filter: every date up to and including the current date.CALCULATE applies this new filter and evaluates [Total Revenue] within it.The result: for the March 2024 row, DAX sums revenue from every date from the beginning of your data through March 31, 2024.
Warning
This v1 measure has a critical flaw in real-world reports. Because we used ALL('Date'), we've also removed any date-related slicer the user has applied. If a user selects "2024" in a year slicer, your cumulative total will still pull data from 2022 and 2023. This is almost never what you want.
The standard fix is to replace ALL('Date') with ALLSELECTED('Date'):
Cumulative Revenue v2 =
VAR CurrentDate = MAX( 'Date'[Date] )
RETURN
CALCULATE(
[Total Revenue],
FILTER(
ALLSELECTED( 'Date' ),
'Date'[Date] <= CurrentDate
)
)
ALLSELECTED is a nuanced function. It removes the filter context imposed by the current visual (the row or column context) but preserves filters that came from outside the visual — slicers, page-level filters, report-level filters, and cross-filter interactions from other visuals.
So if a user has a year slicer set to "2024," ALLSELECTED('Date') will only include 2024 dates in its pool, and your cumulative total will reset at January 2024 and accumulate only through the visible range. This is the behavior 90% of business users expect.
Here's what it looks like in a table visual with a region slicer set to "North":
| Month | Revenue | Cumulative Revenue |
|---|---|---|
| Jan 2024 | 142,500 | 142,500 |
| Feb 2024 | 198,300 | 340,800 |
| Mar 2024 | 175,600 | 516,400 |
| Apr 2024 | 221,900 | 738,300 |
Change the slicer to "South" and both columns update — Cumulative Revenue correctly accumulates only South region data from January.
Key insight
ALLSELECTED works by capturing the "shadow filter context" from the outer query context — the state of all filters that existed before the visual started iterating its rows. This is elegant but can produce unexpected results when you nest ALLSELECTED inside complex measure calculations. For most standard cumulative patterns, it's exactly right.
Here's where many developers run into their second surprise. When users expand a date hierarchy in a matrix — going from Year → Quarter → Month → Day — the filter context at each level only contains the dates relevant to that node. MAX('Date'[Date]) at the Quarter level returns the last day of that quarter, which is correct. But at the Year level, it returns December 31 of that year, which means your cumulative total at the Year level equals your year-to-date total at year-end — which is actually correct year-total behavior.
The problem arises when your visual is a simple table or chart showing only months, but the date column you're using is a date hierarchy field rather than the actual Date column. In this case, the filter context might be incomplete. The safest pattern is to filter on the Date column directly in your FILTER function (which we've been doing), and use MAX('Date'[Date]) to capture the boundary. This works correctly regardless of which level of a date hierarchy is active.
For more complex date hierarchy scenarios, including fiscal year hierarchies where your calendar year and business year don't align, see Advanced Time Intelligence: Custom Calendars, Fiscal Years, and ISO Weeks for dedicated patterns.
A common business requirement is a cumulative total that resets at the start of each fiscal year. Let's say your fiscal year runs from April 1 to March 31. You want January 2024 to show cumulative revenue since April 2023, not since the beginning of all time.
We need to add a lower boundary to our FILTER condition:
Cumulative Revenue YTD (Fiscal) =
VAR CurrentDate = MAX( 'Date'[Date] )
VAR CurrentFiscalYear = MAX( 'Date'[FiscalYear] )
RETURN
CALCULATE(
[Total Revenue],
FILTER(
ALLSELECTED( 'Date' ),
'Date'[Date] <= CurrentDate
&& 'Date'[FiscalYear] = CurrentFiscalYear
)
)
This uses a two-condition filter: the date must be on or before the current date AND it must fall in the same fiscal year. Because FiscalYear is a column in your Date table that correctly labels April–March periods, this gives you a fiscal YTD that resets automatically at the right boundary.
Tip
DAX's built-in time intelligence functions like TOTALYTD can accept a custom year-end date parameter, but they only work with calendar-aware dates. For true fiscal year logic with custom calendars, the FILTER approach shown above is more flexible and transparent. The article on Time Intelligence in DAX: YTD, MTD, Previous Period, and Rolling Averages covers the TOTALYTD approach and its limitations in depth.
Cumulative minimum is conceptually simpler than it sounds: for each row in your visual, return the smallest value seen across all periods up to and including the current one. This is useful for things like "lowest daily closing price to date," "minimum weekly inventory level seen this quarter," or "best (lowest) customer acquisition cost achieved so far this year."
The naive approach uses the same FILTER pattern but swaps the aggregation:
Cumulative Min Revenue (Wrong) =
VAR CurrentDate = MAX( 'Date'[Date] )
RETURN
CALCULATE(
MIN( Sales[Revenue] ),
FILTER(
ALLSELECTED( 'Date' ),
'Date'[Date] <= CurrentDate
)
)
This actually works in many simple cases, but it has a subtle problem: MIN(Sales[Revenue]) finds the minimum transaction revenue — the single smallest individual sale — across all dates up to now. If you have 50,000 transactions, you're likely to get the same tiny number every single month because there's always some small transaction near the bottom.
What you usually want is the minimum of a measure aggregated by period — for example, the minimum of your monthly total revenue looking back across all months to date. That requires an iterator:
Cumulative Min Monthly Revenue =
VAR CurrentDate = MAX( 'Date'[Date] )
RETURN
CALCULATE(
MINX(
VALUES( 'Date'[Year] & '-' & FORMAT('Date'[MonthNumber], "00") ),
[Total Revenue]
),
FILTER(
ALLSELECTED( 'Date' ),
'Date'[Date] <= CurrentDate
)
)
Actually, the cleaner way to handle this uses a virtual table of month-level summaries:
Cumulative Min Monthly Revenue =
VAR CurrentDate = MAX( 'Date'[Date] )
VAR MonthlyRevenues =
CALCULATETABLE(
ADDCOLUMNS(
SUMMARIZE( 'Date', 'Date'[Year], 'Date'[MonthNumber] ),
"@MonthRevenue", [Total Revenue]
),
FILTER(
ALLSELECTED( 'Date' ),
'Date'[Date] <= CurrentDate
)
)
RETURN
MINX( MonthlyRevenues, [@MonthRevenue] )
Here's what this does step by step:
SUMMARIZE creates a virtual table of unique Year/Month combinations within the filtered date range (all dates up to CurrentDate, respecting slicers)ADDCOLUMNS extends that table with a column containing the revenue for each monthMINX iterates over that month-level table and returns the smallest monthly revenue valueThe result: at March 2024, this measure tells you which month in the entire period up to March 2024 had the lowest total revenue. That's genuinely useful for spotting your worst-performing historical month in context.
Tip
Using VAR to store intermediate table results like MonthlyRevenues isn't just a readability choice — it also prevents DAX from re-evaluating the CALCULATETABLE expression multiple times. For patterns like this where you're building a virtual table and then aggregating it, variables are essential for both clarity and performance. The DAX Variables in Practice article covers this in depth.
The cumulative maximum follows the same pattern. A common business use case: "What is the highest monthly revenue we've ever achieved up to this point?" This is useful for things like peak demand analysis, all-time high tracking, and goal-setting context ("we've never done more than X in a single month before").
Cumulative Max Monthly Revenue =
VAR CurrentDate = MAX( 'Date'[Date] )
VAR MonthlyRevenues =
CALCULATETABLE(
ADDCOLUMNS(
SUMMARIZE( 'Date', 'Date'[Year], 'Date'[MonthNumber] ),
"@MonthRevenue", [Total Revenue]
),
FILTER(
ALLSELECTED( 'Date' ),
'Date'[Date] <= CurrentDate
)
)
RETURN
MAXX( MonthlyRevenues, [@MonthRevenue] )
The only change from the cumulative minimum pattern is MAXX instead of MINX. Everything else is identical.
A powerful combination is showing all three measures side by side — cumulative sum, cumulative min, and cumulative max — in a single table or chart. Imagine a monthly report showing:
| Month | Monthly Revenue | Cumulative Total | Cumulative Min | Cumulative Max |
|---|---|---|---|---|
| Jan 2024 | 142,500 | 142,500 | 142,500 | 142,500 |
| Feb 2024 | 198,300 | 340,800 | 142,500 | 198,300 |
| Mar 2024 | 175,600 | 516,400 | 142,500 | 198,300 |
| Apr 2024 | 221,900 | 738,300 | 142,500 | 221,900 |
| May 2024 | 134,200 | 872,500 | 134,200 | 221,900 |
Notice how in May, Cumulative Min drops to 134,200 because May became the new worst month. This kind of running context is incredibly useful for business review discussions.
Production data is never clean. Your Date table might have entries for every day, but your Sales table might have no transactions on weekends or holidays. When a matrix row corresponds to a date with no sales, [Total Revenue] returns BLANK. That's usually fine — a blank in the visual is correct. But it can break cumulative calculations in unexpected ways.
The issue: if MAX('Date'[Date]) is evaluated in a context where there's truly no date filter (for example, a subtotal row or a grand total row in a matrix), it might return an unexpected value.
Add a guard clause to handle this gracefully:
Cumulative Revenue (Safe) =
VAR CurrentDate = MAX( 'Date'[Date] )
VAR Result =
IF(
ISBLANK( CurrentDate ),
BLANK(),
CALCULATE(
[Total Revenue],
FILTER(
ALLSELECTED( 'Date' ),
'Date'[Date] <= CurrentDate
)
)
)
RETURN Result
This prevents the measure from returning the total of all history when the visual context doesn't provide a meaningful date boundary.
For the grand total row in a matrix, you typically want the cumulative total to show the total across the entire visible range — not accumulate up to the last date. You can detect this situation:
Cumulative Revenue (Smart Total) =
VAR CurrentDate = MAX( 'Date'[Date] )
VAR MinDate = MIN( 'Date'[Date] )
VAR IsGrandTotal = ( MinDate = MINX( ALLSELECTED('Date'), 'Date'[Date] ) )
RETURN
IF(
IsGrandTotal,
[Total Revenue],
CALCULATE(
[Total Revenue],
FILTER(
ALLSELECTED( 'Date' ),
'Date'[Date] <= CurrentDate
)
)
)
When the minimum date in the current context equals the minimum date across all selected dates, we know we're at a grand total level (or at the first period), and we return the simple total instead.
Warning
Grand total detection logic can be brittle. The IsGrandTotal pattern above works for simple tables and matrices, but can misbehave in more complex visual types or when multiple dimensions are involved. Always test your cumulative measures explicitly in a matrix with subtotals enabled before shipping to production.
Cumulative measures that use FILTER(ALLSELECTED(...), ...) involve a row-by-row scan of your Date table for every cell the visual renders. If your Date table has 3,650 rows (10 years of daily dates) and your visual has 36 month rows, DAX executes 36 × 3,650 = 131,400 row evaluations for that one measure. That's not catastrophic, but add more measures, more rows, and a cross-filter from another visual, and query times can grow.
Strategies to keep performance acceptable:
Use a Date table with appropriate granularity. If your analysis never goes below month level, a Date table with one row per month will be dramatically faster than one row per day.
Avoid FILTER on large fact tables. The pattern FILTER(ALL(Sales), ...) on a fact table with millions of rows is the performance killer you want to avoid. Always filter on the Date dimension table, let the relationship propagate, and let the storage engine do its job.
Use CALCULATE with explicit date range arguments when possible. For simple YTD patterns, CALCULATE([Total Revenue], DATESYTD('Date'[Date])) leverages time intelligence caching and is faster than a manual FILTER.
Consider aggregation tables. If you have tens of millions of fact rows and cumulative measures are slow, pre-aggregating to a monthly summary table can dramatically reduce query time.
For deep-dive diagnosis of slow measures, the workflow covered in Performance Tuning DAX: Optimize Slow Measures with DAX Studio is the right next step.
Build this end-to-end in your own Power BI file using the following scenario:
Scenario: You're building a quarterly business review dashboard for a software company. The Sales table has columns: CloseDate, DealValue, SalesRep, Region, ProductLine. The Date table is fully built out with Date, Year, Quarter, MonthNumber, FiscalYear, FiscalMonthNumber.
Step 1: Create the base measure.
Total Deal Value = SUM( Sales[DealValue] )
Step 2: Create a cumulative total that respects slicer selections and resets at fiscal year boundaries.
Cumulative Deal Value (FY) =
VAR CurrentDate = MAX( 'Date'[Date] )
VAR CurrentFY = MAX( 'Date'[FiscalYear] )
RETURN
IF(
ISBLANK( CurrentDate ),
BLANK(),
CALCULATE(
[Total Deal Value],
FILTER(
ALLSELECTED( 'Date' ),
'Date'[Date] <= CurrentDate
&& 'Date'[FiscalYear] = CurrentFY
)
)
)
Step 3: Build the cumulative maximum monthly deal value.
Cumulative Max Monthly Deal Value =
VAR CurrentDate = MAX( 'Date'[Date] )
VAR MonthlyTotals =
CALCULATETABLE(
ADDCOLUMNS(
SUMMARIZE( 'Date', 'Date'[FiscalYear], 'Date'[FiscalMonthNumber] ),
"@MonthTotal", [Total Deal Value]
),
FILTER(
ALLSELECTED( 'Date' ),
'Date'[Date] <= CurrentDate
)
)
RETURN
IF(
ISBLANK( CurrentDate ),
BLANK(),
MAXX( MonthlyTotals, [@MonthTotal] )
)
Step 4: Build a matrix visual with Month on rows, and add columns for Total Deal Value, Cumulative Deal Value (FY), and Cumulative Max Monthly Deal Value. Add a Region slicer and a FiscalYear slicer.
Step 5: Test these interactions:
Bonus challenge: Add a measure that shows whether the current month's deal value is above or below the running maximum:
New All-Time High? =
VAR CurrentMonthRevenue = [Total Deal Value]
VAR PriorMax =
VAR CurrentDate = MAX( 'Date'[Date] )
VAR PriorMonthDate = EDATE( MAX( 'Date'[Date] ), -1 )
VAR MonthlyTotals =
CALCULATETABLE(
ADDCOLUMNS(
SUMMARIZE( 'Date', 'Date'[FiscalYear], 'Date'[FiscalMonthNumber] ),
"@MonthTotal", [Total Deal Value]
),
FILTER(
ALLSELECTED( 'Date' ),
'Date'[Date] <= PriorMonthDate
)
)
RETURN MAXX( MonthlyTotals, [@MonthTotal] )
RETURN
IF( CurrentMonthRevenue > PriorMax, "🏆 New High", "" )
Problem: Cumulative total is the same value in every row
This almost always means MAX('Date'[Date]) isn't finding the date you think it is. Check that:
Problem: Cumulative total doesn't reset when expected
If you're using ALLSELECTED('Date') and the total isn't resetting with your fiscal year slicer, verify that your slicer is filtering the Date table (not the fact table's date column). Slicers on fact table columns bypass the dimension relationships and won't affect ALLSELECTED('Date') correctly.
Problem: Grand total row shows an unexpectedly large number
The grand total row in a matrix often has a broader filter context than individual rows. Your MAX('Date'[Date]) at the grand total level might be returning the latest date across all selected dates, causing the cumulative total to equal the total revenue for the entire period — which is technically correct cumulative behavior, but might confuse users. Use the smart total pattern shown earlier to return a simple total at the grand total level.
Problem: Measure returns BLANK in some rows where data exists
This can happen when the visual is using a date hierarchy field that generates a filter on the Year or Month number rather than the Date column directly. Verify that your FILTER condition references 'Date'[Date] (the actual date column), and that your Date table has no gaps in dates that could cause relationships to miss.
Problem: Performance is unacceptably slow
Profile with DAX Studio. If the bottleneck is in the FILTER + ALLSELECTED pattern, consider:
DATESYTD which is storage-engine optimizedKey insight
Most DAX performance problems with cumulative measures come from filtering fact tables directly instead of dimension tables. Always structure your FILTER to work on the Date table, and let the relationship propagate the filter to the fact table. The storage engine handles set operations on dimension tables much more efficiently than row-by-row scanning of fact tables.
Cumulative calculations in DAX are one of those areas where understanding the why pays enormous dividends. The core pattern — CALCULATE + FILTER + ALLSELECTED with a date boundary captured in a variable — gives you a foundation that extends to virtually any "running" calculation you'll encounter in practice.
Here's what to take away:
ALL('Date') removes all date filters, including slicers — use it only when you explicitly want to ignore user selectionsALLSELECTED('Date') preserves slicer and cross-filter context — this is the right choice for 90% of cumulative measuresSUMMARIZE + ADDCOLUMNS + MINX/MAXX rather than applying MIN/MAX directly to fact columnsISBLANK protect against blank rows and unexpected grand total behaviorWhere to go next:
If you're working in financial reporting contexts where cumulative logic intersects with balance sheet calculations, the DAX for Semi-Additive Measures article covers the specific challenge of non-additive measures like inventory levels and account balances that can't simply be summed across time.
For cumulative patterns that need to work across complex many-to-many relationships — for example, cumulative revenue attributed to customers who belong to multiple segments — the approaches in DAX Aggregation Over Filtered Subsets: Mastering CALCULATE with KEEPFILTERS, REMOVEFILTERS, and Boolean vs. Table Filters will show you how to manage filter context manipulation without breaking your model's relationship logic.
And if you're ready to level up the visual sophistication of your running calculations — adding comparative analysis, ranking by cumulative value, or showing which period achieved a new record high — the patterns in Mastering DAX Window Functions: RANK, ROWNUMBER, and OFFSET for Advanced Comparative Analysis complement cumulative measures beautifully.