DAX function
FIRSTDATE / LASTDATE — DAX function reference
First/last date in context.
Syntax
dax
FIRSTDATE(<dates>) LASTDATE(<dates>)
Examples
dax
LASTDATE('Date'[Date])→ A date
Often used as the opening side of an opening/closing balance pair.
dax
CALCULATE(SUM(Sales[Amount]), FIRSTDATE('Date'[Date]))→ Sales on the earliest date currently in context
The standard pattern for non-additive measures like inventory or headcount.
dax
CALCULATE([Total Inventory], LASTDATE('Date'[Date]))→ Closing/point-in-time balance
Common mistakes & gotchas
- FIRSTDATE/LASTDATE return a one-row table of the min/max date in context, not a scalar — that’s why they’re typically wrapped in CALCULATE, though DAX implicitly coerces a single-row, single-column table to a scalar in most contexts.
- They differ from plain MAX('Date'[Date]): FIRSTDATE/LASTDATE are the time-intelligence-aware building blocks other functions like SAMEPERIODLASTYEAR use internally and behave predictably with non-contiguous selections, while MAX is a simpler scalar aggregation that’s fine (and faster) for most report measures.
Related DAX functions
From Time intelligence