DAX DATESYTD Function
Calculate values **from the beginning of the year up to a specific date in DAX.
The DATESYTD()
function in DAX is a time intelligence function used to calculate values
from the beginning of the year up to a specific date.
Purpose
DATESYTD()
returns a table of dates from the start of the year up to the latest date in the current
filter context. It’s commonly used for calculating Year-To-Date (YTD) values like revenue, sales, profit, etc.
Syntax
DATESYTD(<dates>, [<year_end_date>])
Parameters
<dates>
→ A column of date values (usually from a Date table)[<year_end_date>]
(optional) → The fiscal year-end (e.g., "06-30" for June 30). If omitted, defaults to December 31.
Example
Total Sales YTD =
CALCULATE(
SUM(Sales[Amount]),
DATESYTD('Date'[Date])
)
This measure returns the cumulative total of Sales[Amount] from the beginning of the year up to the selected date.
Fiscal Year Example
If your fiscal year ends on March 31, you can write:
Total Sales FY YTD =
CALCULATE(
SUM(Sales[Amount]),
DATESYTD('Date'[Date], "03-31")
)
Key Points
- Requires a proper Date table with a continuous range of dates.
- Automatically respects filter context (e.g., slicers, visuals).
- Works only with standard or fiscal years, not custom periods (e.g. quarters).
Used With
Function | Use |
---|---|
CALCULATE() | To apply the DATESYTD table as a filter |
TOTALYTD() | Shortcut to calculate totals using DATESYTD |
DATEADD() | For YTD comparison with previous years |
Visualization Example
If you're visualizing monthly revenue:
SUM(Sales[Amount])
shows actual values by month.CALCULATE(SUM(Sales[Amount]), DATESYTD(...))
shows cumulative YTD totals month over month.
No questions available.