Sub topic 13
Blanking future and incomplete periods
This chapter assumes you have a marked date table related to your fact table, and that you can already write the year-to-date measure Sales YTD and the prior-year measure Sales PY from earlier chapters. It covers why those measures keep returning numbers after your data ends, and how to stop them.
Why future dates still show values
A date table built with CALENDAR covers every day through 2025-12-31. Suppose the last sale in the Sales table is on 2025-09-18, and you put months on the rows of a matrix. The Total Sales measure is blank for October, November and December, because no fact rows exist for those dates.
Sales YTD is different. TOTALYTD evaluates Total Sales over every date from January 1 to the last date in the current filter context. For December, that range includes all the real sales from January through September. The result is the September total, repeated for each remaining month.
A line chart of this measure rises through September and then runs flat to December. The measure is correct for what it was asked, but the chart suggests sales stopped growing.
| Month | Total Sales | Sales YTD (uncapped) | Sales YTD Capped |
|---|---|---|---|
| 2025-08 | 90 | 700 | 700 |
| 2025-09 | 40 (partial) | 740 | 740 |
| 2025-10 | blank | 740 | blank |
| 2025-12 | blank | 740 | blank |
The table uses made-up numbers to show the pattern.
Cap the measure at the last date with data
The fix is to find the last date that has sales and return a value only when the visible period starts on or before it. This is the measure from the plan:
Sales YTD Capped =
VAR LastSaleDate =
CALCULATE ( MAX ( Sales[Order Date] ), ALL ( 'Date' ) )
VAR CurrentLastDate = MAX ( 'Date'[Date] )
RETURN
IF ( CurrentLastDate <= LastSaleDate, [Sales YTD] )ALL ( 'Date' ) matters here. Without it, the relationship from the Date table filters Sales to the dates in the current cell. In the December row, MAX ( Sales[Order Date] ) would then return blank, and the comparison would never work the way you intend.
IF has no else branch, so it returns blank when the test is false. Power BI draws no point for a blank, so the line stops at the last month with data.
The test uses MAX ( 'Date'[Date] ), which is the last date in the cell. In the September row that is 2025-09-30, which is after 2025-09-18, so a strict test blanks September itself. That is a real edge case. The next section covers it.
Decide what "incomplete" means
A month that contains the last sale date is partly complete. You have three choices, and each is a business decision.
- Show the partial month. Compare the cap against the first date of the period, so the period shows once it has started.
- Show only complete periods. Blank the period unless its last date is on or before the last sale date.
- Show the partial month, but compare it fairly. Limit the prior-year side to the same dates.
The first choice looks like this:
Sales YTD Started =
VAR LastSaleDate =
CALCULATE ( MAX ( Sales[Order Date] ), ALL ( 'Date' ) )
VAR CurrentFirstDate = MIN ( 'Date'[Date] )
RETURN
IF ( CurrentFirstDate <= LastSaleDate, [Sales YTD] )For a month cell, MIN returns the first of the month. September starts before 2025-09-18, so it shows. October starts after it, so it is blank. At year level, a 2025 cell shows because January 1 is before the last sale. Use MIN when partial periods are acceptable and MAX when only complete periods should appear.
Reuse the last date in a separate measure
Writing the same variable in every measure invites inconsistency. Define it once:
Last Sale Date =
CALCULATE ( MAX ( Sales[Order Date] ), ALL ( 'Date' ) )
Sales YTD Started =
IF ( MIN ( 'Date'[Date] ) <= [Last Sale Date], [Sales YTD] )
Sales PY Started =
IF ( MIN ( 'Date'[Date] ) <= [Last Sale Date], [Sales PY] )The measure still respects filters on other tables. If a slicer selects the Region "North", Last Sale Date is the last date North sold anything. A region that stopped selling in August then goes blank after August. That is often what you want. If you need one global cutoff for every slice, remove all filters:
Last Sale Date (Global) =
CALCULATE ( MAX ( Sales[Order Date] ), REMOVEFILTERS () )REMOVEFILTERS () with no arguments clears every filter in the model for that calculation, including the Date table filter, so you do not need ALL ( 'Date' ) as well.
Compare a partial period fairly
Once September has data only through the 18th, the prior-year comparison is unfair. Sales PY returns all of September 2024. The year-over-year growth then looks bad only because the current month is short.
To compare like with like, keep only the visible dates that are on or before the last sale date, then shift that set back a year:
Sales PY Comparable =
VAR LastSaleDate = [Last Sale Date]
VAR VisibleDates =
FILTER ( VALUES ( 'Date'[Date] ), 'Date'[Date] <= LastSaleDate )
RETURN
CALCULATE ( [Total Sales], SAMEPERIODLASTYEAR ( VisibleDates ) )VALUES ( 'Date'[Date] ) gives the dates in the current cell. For September that is the 30 days of the month. FILTER reduces them to September 1 through 18, and SAMEPERIODLASTYEAR moves that set to September 1 through 18, 2024. For October the filtered set is empty, so the measure returns blank.
You can then build a growth percentage on it:
Sales YoY % Comparable =
VAR CurrentSales = [Total Sales]
VAR PriorSales = [Sales PY Comparable]
RETURN
DIVIDE ( CurrentSales - PriorSales, PriorSales )For a fully completed month the result matches your earlier Sales YoY %. Only the partial month differs.
Do not blank by testing the total for blanks
A shortcut is to blank the measure whenever Total Sales is blank:
Sales YTD Shortcut =
IF ( NOT ISBLANK ( [Total Sales] ), [Sales YTD] )This hides future months, but it also hides any past month that had no sales. A seasonal business with no sales in February would show a gap in its YTD line, even though the cumulative total did not change. The date-based test avoids this, because it only blanks dates after the last recorded sale.
Incomplete windows in moving averages
Moving averages have a second incomplete-period problem at the start of the data, not the end. Take the 30-day average:
Sales 30 Day Avg Full =
VAR LastDate = MAX ( 'Date'[Date] )
VAR Window = DATESINPERIOD ( 'Date'[Date], LastDate, -30, DAY )
VAR DaysInWindow = COUNTROWS ( Window )
RETURN
IF (
DaysInWindow = 30 && LastDate <= [Last Sale Date],
AVERAGEX ( Window, [Total Sales] )
)DATESINPERIOD only returns dates that exist in the Date table. On 2020-01-10 the window holds 10 days, not 30, so an average over it is not a 30-day average. The DaysInWindow = 30 test blanks those early dates. The LastDate <= [Last Sale Date] test blanks dates after the data ends.
Remember that AVERAGEX skips days where Total Sales is blank. A day with no sales is therefore left out of the average, not counted as zero. If you want zeros, use AVERAGEX ( Window, [Total Sales] + 0 ).
Other ways to limit the date range
Limiting the Date table itself is a different approach. You could build it with CALENDAR ( MIN ( Sales[Order Date] ), MAX ( Sales[Order Date] ) ), so it ends at the last sale. Future months then never appear.
- This removes the flat-line problem for months, because there are no future rows.
- It still leaves a partial final period, and the cutoff changes with every refresh, which can break reports that expect a full year.
- It also removes dates that other tables, such as a budget, may need.
Most models keep a full-year date table and blank the measures instead.
Check your work
- Put
Date[Year Month]on the rows of a matrix withTotal Sales,Sales YTD, and the capped version. - Confirm that the capped version is blank for every month after the last sale date.
- Look at the month containing the last sale date, and check that the result matches the choice you made (partial shown or blank).
- Filter the matrix to a region or product with fewer sales, and check that
Last Sale Datebehaves the way you intended.
Exercise
Your data's last sale is on 2025-09-18. A matrix of months shows Sales YTD Capped, built with MAX ( 'Date'[Date] ) <= [Last Sale Date]. September shows blank even though it has real sales. Which change makes September show, and why does October still stay blank?
Show answer
Replace MAX ( 'Date'[Date] ) with MIN ( 'Date'[Date] ) in the test. In the September cell, MAX is 2025-09-30, which is after 2025-09-18, so the test fails and the measure is blank. MIN is 2025-09-01, which is on or before the last sale date, so September shows. In the October cell, MIN is 2025-10-01, which is after the last sale date, so the test fails and October stays blank.
Exercise
Why does Sales PY Comparable return blank for October 2025, and what would a plain Sales PY return there?
Show answer
In the October cell, FILTER keeps only dates on or before the last sale date, 2025-09-18. All October dates are later, so the filtered set is empty, SAMEPERIODLASTYEAR of it is empty, and CALCULATE returns blank. A plain Sales PY shifts all of October 2025 back to October 2024 and returns that month's full sales, so it still shows a value for a month with no current data.