<!-- https://learnsql.cpetoday.com/functions/dax/datesytd -->
# DATESYTD

Language: DAX
Category: Time intelligence: to date
Syntax: DATESYTD(<dates> [, <year_end_date>])
Summary: Returns a table of dates from the start of the year up to the last date in the filter context.
Returns: A table of dates, used as a filter inside CALCULATE.
Level: Intermediate
Related: TOTALYTD, DATESQTD, CALCULATE, STARTOFYEAR, DATESBETWEEN

## What it does
DATESYTD returns the list of dates from the start of the year to the last date in the current context. CALCULATE uses that list as a filter, so any measure can be shown year to date. It does the same job as TOTALYTD, but it gives you control. You can add other filters inside CALCULATE, or use the dates in other functions.

## Syntax and arguments
- dates: the date column of the Calendar table. Required.
- year_end_date: the fiscal year end as text, such as "6/30". Optional. Leave it out for a calendar year.

## Example
A company with a June 30 year end wants cash receipts from customers year to date. The receipts are in a Payments table with a PaymentDate column that is related to the Calendar.

```dax
Receipts YTD =
CALCULATE(
    SUM('Payments'[Amount]),
    DATESYTD('Calendar'[Date], "6/30")
)
```

In a November 2026 column, the filter covers July 1, 2026 through November 30, 2026. Receipts before July 1 are excluded, so the figure is the fiscal year to date.

## Example: a second, different use
Year to date cash receipts for one customer group, with a second filter inside CALCULATE. The date filter and the customer filter combine.

```dax
Wholesale Receipts YTD =
CALCULATE(
    SUM('Payments'[Amount]),
    DATESYTD('Calendar'[Date]),
    'Customers'[Segment] = "Wholesale"
)
```

## Things to watch
- DATESYTD returns a table, not a number. Use it inside CALCULATE as a filter, or as the table for an iterator such as SUMX.
- The result follows the Calendar's date column. Using the date column of a fact table gives different results.
- The year end argument is text in month/day form, like TOTALYTD. A calendar year needs no argument.
- Test the measure on a month row and on a year row, so you can see what the filter returns in each place it will be used.

## In business terms
DATESYTD is the building block for year to date receipts, payments and accruals, and for any balance or flow measure that must reset each fiscal year. Finance teams use it when a measure needs an extra filter that TOTALYTD does not cover easily.
