<!-- https://learnsql.cpetoday.com/functions/dax/lastdate -->
# LASTDATE

Language: DAX
Category: Time intelligence: first and last
Syntax: LASTDATE(<dates>)
Summary: Returns the last date in the filter context, as a one-row table.
Returns: A table with one date, used as a filter inside CALCULATE.
Level: Intermediate
Related: FIRSTDATE, LASTNONBLANK, ENDOFMONTH, MAX, CALCULATE

## What it does
LASTDATE finds the latest date in the current filter context. Inside CALCULATE it pins a measure to that one day. Finance teams use it to read a balance as of the report date or on the last day of the period, such as the closing cash balance for a month. It returns the last date in the context whether or not data exists on that day, so a missing row gives a blank.

## Syntax and arguments
- dates: the date column of the Calendar table. Required.

## Example
A treasury dashboard shows the closing bank balance for the period on the last day of the period. The balance table has one row per account per day.

```dax
Cash Closing (last day) =
CALCULATE(
    SUM('Bank_Balances'[Balance]),
    LASTDATE('Calendar'[Date])
)
```

In a row for October 2026, the measure returns the balance on October 31, 2026. In a row for a single day, it returns that day's balance.

## Example: a second, different use
The last transaction date for one customer. MAX reads the fact table, because LASTDATE reads the Calendar and would return the last calendar day in the view.

```dax
Last Invoice Date = CALCULATE(MAX('Invoices'[InvoiceDate]))
```

## Things to watch
- LASTDATE returns the last date in the context, even when there is no data on it. For the last date that has data, use LASTNONBLANK.
- For the last transaction date in a fact table, use MAX on the fact date column, not LASTDATE on the Calendar.
- In a report with a date slicer, LASTDATE follows the slicer. A report date that is set by a parameter is more predictable.
- A balance read on the last day is the closing position. Check it against the closing trial balance for the same date.

## In business terms
LASTDATE supports closing balances, the as-of balance on a report date, and the closing position used in the month-end pack. Lenders and auditors ask for "the balance as of" a date, which is what LASTDATE returns.
