The Power BI DATESYTD function is one of the DAX Date and Time functions useful for returning a table of continuous dates for the year to date. This article explains the POWER BI DAX DATESYTD function, which accepts the date value and uses the current context to return a column of dates for the year to date. The syntax is shown below.
DATESYTD(<dates>)
For the DATESYTD function, you can use the column that contains the date/time value. Otherwise, use the table expression that returns a single column as the parameter.
Power BI DAX DATESYTD function Example
To demonstrate the DAX DATESYTD() function, click the New Measure button on the Modeling Tab and rename it as RunSalesYTD. The expression below calculates the sum of the sales amount in the FactInternetSales table for each year.
Here, we used the CalendarTable generated by the CALENDAR function. If we add the below expression to the table report it will calculate the running total for each year of the Order date and restart at next year. Please refer to the DateTime and function article for the remaining Power BI methods. For more Charts >> Click Here.
RunSalesYTD = CALCULATE(SUM(FactInternetSales[SalesAmount]), DATESYTD(CalendarTable[Date]))
In the expression below, we used the FILTER method to restrict the use of DATESYTD for the year 2012. This formula calculates the running total for the 2012 calendar year.
RunSalesYTD2012 = CALCULATE(SUM(FactInternetSales[SalesAmount]), DATESYTD(CalendarTable[Date]), FILTER(CalendarTable, CalendarTable[Date].[Year] = 2012))