Forum Discussion
Previous Year calculation
Thank you CNENFRNL . I think I was not able to make my point clear to you so let me explain my situation.
When I use the dax Max(sales date) and put it in a card I get the following visual.
My question is what dax should I write to get the Previous year which is 2019 similarly in the card.
If I try to do Min( Sales date) I get 2018 but I need 2019. I tried using dateadd but it does not return the Year in the way I need. Thanks
Hi BishwaR ,
Since there is no date column in your dataset, you use the year as a slicer and create measures like this:
CY =
CALCULATE (
SUM ( 'Table'[Sales] ),
FILTER (
ALL ( 'Table' ),
'Table'[Year] = SELECTEDVALUE ( 'Table'[Year] )
&& 'Table'[Dept] IN DISTINCT ( 'Table'[Dept] )
)
)
PY =
CALCULATE (
SUM ( 'Table'[Sales] ),
FILTER (
ALL ( 'Table' ),
'Table'[Year]
= SELECTEDVALUE ( 'Table'[Year] ) - 1
&& 'Table'[Dept] IN DISTINCT ( 'Table'[Dept] )
)
)
Attached a sample file in the below, hopes to help you.
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.