⏱️ DAX Reference - Day 18/237: LASTDATE — it returns the same date as MAX, so why does it exist?
Yesterday's post ended with an idiom: when you read MAX('Date'[Date]), hear "the last visible date." Today, the natural question — DAX has a function literally named for that job. LASTDATE('Date'[Date]) points at the very same date. Two functions, one answer. The difference isn't the value; it's the type, and the type decides where each one belongs.
MAX returns a scalar — a naked value. LASTDATE returns a one-row table that still remembers which column it came from. That memory (lineage) is what lets it drop straight into CALCULATE as a filter:
Shipments on Last Day = CALCULATE(COUNTROWS(Shipment), LASTDATE('Date'[Date]))
Whatever period the visual shows — a month, a quarter, a year — only the closing day's shipments count. That's the snapshot pattern, the standard shape for closing balances, stock levels, and headcounts, and it's where LASTDATE earns its keep. MAX can't sit in that position on its own.
Where the twins swap places: inside iterators and FILTER conditions. LASTDATE is CALCULATE-based, so in a row context it quietly performs a context transition — the classic trap that makes a formula slower and occasionally just wrong, with nothing visibly broken. In row-context logic, MAX gives the same date with no hidden machinery.
One more edge: LASTDATE demands data on that exact day. If the period's last day can be empty — weekends, holidays, a warehouse that doesn't count stock daily — the snapshot silently returns blank, and LASTNONBLANK is the tool instead.
Rule of thumb: in filter arguments, LASTDATE; everywhere else, MAX. Same date, different types — and the type is the whole difference.
🤔 What are your best practices with the LASTDATE function?
📚 Learn more: https://powerbi-masterclass.com/public/article/dax-reference-lastdate?utm_campaign=telegram
👉 Get all our Power BI tutorials: https://powerbi-masterclass.short.gy/power-bi?utm_campaign=telegram
💻 Practice LASTDATE with our Power BI GPT Coach: https://chatgpt.com/g/g-68554431f9608191b9b40505c423fc6e-power-bi-coach-and-assistant?prompt=Help%20me%20practice%20LASTDATE%20function&utm_campaign=telegram