Orders that ship next month: compare a key with the visible dates
Count order lines placed this month that ship after it ends — and see that the date filter reaches Sales only through the order date.
You will learn to
- Explain which Sales date column a Date filter reaches
- Capture the last visible date key in a variable
- Compare number keys safely (ordering, not arithmetic)
How it works
When a visual filters to March 2025, the filter reaches Sales through the **active** relationship on `Sales[DateKey]`. `Sales[ShipDateKey]` isn’t filtered at all: it’s just a column of numbers riding along on each order line, and some of those numbers fall in April.
Date keys are written as **yyyymmdd** numbers (20250315). That makes them safe to **compare** — a later day is always a bigger number — but not to subtract: 20250301 minus 20250228 is 73, not 1.
`MAX('Date'[DateKey])` returns the last day visible in the current cell. Store it in a variable first, then use it inside an iterator over Sales.
Practice it hands-on with a real data model and a live report that updates as you type.
Lines on Last Day =
VAR LastDay = MAX('Date'[DateKey])
RETURN COUNTROWS(FILTER(Sales, Sales[DateKey] = LastDay))