First I calculated Year to date written Premiu:
YTD WP = TOTALYTD([Ttl WP],dim_Date[Date]) //works fine
Then in order to calculate the same for previous year I'm using SAMEPERIODLASTYEAR
function:
PY WP = CALCULATE([YTD WP],
SAMEPERIODLASTYEAR(dim_Date[Date]), ALL(dim_Date)
)
The result should be $72,550 M. Where does it get $127.60M???
So, unfortunately it does not give me correct result.
I have similar report already and function works fine, but why it doesn't work in this situation?
UPDATE 1:
Using DATESYTD to get numbers for previous year also gives me 127M
PY WP = CALCULATE([YTD WP],
DATEADD(DATESYTD(dim_Date[Date]),-1,YEAR)
)
UPDATE 2:
PY WP = CALCULATE(
[YTD WP], SAMEPERIODLASTYEAR(DATESYTD(dim_Date[Date])), ALL(dim_Date)
)
UPDATE 3:
Marked dim_Date table as "Date" table.
PY WP = TOTALYTD([Ttl WP], SAMEPERIODLASTYEAR(dim_Date[Date]))
But still gives incorrect number.
I used filter function to make sure what is the number should be:
PrevYear = CALCULATE([Ttl WP],FILTER(dim_Date,dim_Date[Date] >=VALUE("2018-01-01") && dim_Date[Date] <=VALUE("2018-03-31")))
And I got correct number.
dim_Date[Date]
withDATESYTD
in yourPY WP
measure? – Alexis OlsonPY WP = CALCULATE([YTD WP], DATEADD(DATESYTD(dim_Date[Date]),-1,YEAR) )
– SerdiaPY WP = CALCULATE([YTD WP], SAMEPERIODLASTYEAR(DATESYTD(dim_Date[Date])), ALL(dim_Date) )
, but I don't remember if you can even pass in an expression to that function. – Alexis OlsonALL(dim_Date)
toCALCULATE
? Do you meanALL(fact_premium)
? – World Wide DBA