Forum Discussion
alison_mergaman
9 years agoFrequent Visitor
Last Year compared to Current YTD
I am attempting to calculate Last year compared to the current year to date. So for my data, I have information as current as of August 2nd, 2017. I want a comparison for that date in 2016. I was abl...
- 9 years ago
Hi alison_mergaman,
Based on my tests, the formula below should work in your scenario. :smileyhappy:
Exams LY = VAR maxDate = LASTDATE ( v_Master_Item_Detail[TransactionDate] ) VAR minDate = FIRSTDATE ( v_Master_Item_Detail[TransactionDate] ) RETURN CALCULATE ( [Exams], FILTER ( ALL ( v_Master_Item_Detail ), v_Master_Item_Detail[TransactionDate] <= DATEADD ( maxDate, -1, YEAR ) && v_Master_Item_Detail[TransactionDate] >= DATEADD ( minDate, -1, YEAR ) ) )Regards
v-ljerr-msft
Microsoft Employee
9 years agoHi alison_mergaman,
Based on my tests, the formula below should work in your scenario. :smileyhappy:
Exams LY =
VAR maxDate =
LASTDATE ( v_Master_Item_Detail[TransactionDate] )
VAR minDate =
FIRSTDATE ( v_Master_Item_Detail[TransactionDate] )
RETURN
CALCULATE (
[Exams],
FILTER (
ALL ( v_Master_Item_Detail ),
v_Master_Item_Detail[TransactionDate] <= DATEADD ( maxDate, -1, YEAR )
&& v_Master_Item_Detail[TransactionDate] >= DATEADD ( minDate, -1, YEAR )
)
)
Regards
alison_mergaman
9 years agoFrequent Visitor
v-ljerr-msft Please ignore my last message!!! This code worked!!! I had to use ALLEXCEPT because I have filters for my report. Thank you so much!!!!