First and last day of a period with FIRSTDATE and LASTDATE
Find the first and last calendar day in any period and calculate sales on the closing day, knowing why some months come back blank.
You will learn to
- Explain what FIRSTDATE and LASTDATE return
- Filter a measure to the last day of a period
- Read blanks on days with no sales correctly
How it works
`FIRSTDATE('Date'[Date])` and `LASTDATE('Date'[Date])` return the first and last date **visible in the Date table** for the current row, as a one-row table. In the March 2025 row they are 1 March and 31 March 2025; in the 2024 row, 1 January and 31 December 2024.
They read the **calendar**, not the sales. The Date table has every day, so LASTDATE of a month is always the month end, even if the last sale was on the 27th. To find the date of the last sale you would need to look in Sales instead.
Because the result is a table of dates, it works as a `CALCULATE` filter: sales on exactly that one day. That is the pattern for closing balances and end-of-period snapshots. When nothing was sold on that day, the result is blank, which is the honest answer.
Practice it hands-on with a real data model and a live report that updates as you type.
First Day Sales = CALCULATE([Total Sales], FIRSTDATE('Date'[Date]))