Trying to calculate YTD for several dates in DAX STUDIO according to https://www.daxpatterns.com/time-patterns/ guide
I've created a measure in my model, which gets the job done when I use Date Dimension and calculates YTD for every date
CALCULATE (
[Sales Amt],
FILTER (
ALL ( 'Date' ),
'Date'[Year] = MAX ( 'Date'[Year] )
&& 'Date'[Date] <= MAX ( 'Date'[Date] )
)
)
But when I'm trying to reproduce the same result using DAX Studio, I get correct result only when I filter CALCULATETABLE for a certain date
This code works perfectly:
EVALUATE
CALCULATETABLE(
ADDCOLUMNS (
VALUES ( 'Date'[Date] ),
"YTD", CALCULATE (
[Sales Amt],
FILTER (
ALL ( 'Date' ),
'Date'[Year] = MAX ( 'Date'[Year] )
&& 'Date'[Date] <= MAX ( 'Date'[Date] )
)
)
)
,
'Date'[Date] = DATE(2018,5,1)
)
This code is expected to return YTD for every date in rows, but, unfortunately it doesn't. What am I doing wrong?:
EVALUATE
CALCULATETABLE(
ADDCOLUMNS (
VALUES ( 'Date'[Date] ),
"YTD", CALCULATE (
[Sales Amt],
FILTER (
ALL ( 'Date' ),
'Date'[Year] = MAX ( 'Date'[Year] )
&& 'Date'[Date] <= MAX ( 'Date'[Date] )
)
)
)
,
'Date'[Date] >= DATE(2018,5,1)
)
The only difference is = vs >=, but I get empty result for all the rows