I have a table with sales per item per date and i want to add a year to date measure with DAX. Now in Excel what i used to do is add a YTD column which checks if the date (without the year) is in the constraints of the year to date range and return a 0 or a 1. This made it possible to sum the year to date values for this year and the previous years.
Now in DAX i do not now how to get it working, i tried this one but did only give a total ytd result on each date line.
DAX Last Year to Date
What i want to achieve is the below table but with sales ytd not as a total and the sales YTD LY also not as a total.
This is my sales ytd formula that contains al the relevant columns i guess
Sales YTD =
VAR MaxDate = CALCULATE(MAX('Input Analysefile'[Date]), ALL('Input Analysefile'))
VAR CurrentYear = YEAR(MaxDate)
RETURN
CALCULATE(
SUM('Input Analysefile'[Omzet]),
FILTER(
ALL('Input Analysefile'[Date]),
YEAR('Input Analysefile'[Date]) = CurrentYear &&
'Input Analysefile'[Date] <= MaxDate &&
'Input Analysefile'[Date] >= DATE(CurrentYear, 1, 1)
)
)