Forum Discussion
Previous Year calculation
Hi, BishwaR , did you give a shot to DATEADD(Sales[Date], -1, YEAR)? It's a common way to filter down to previous year; but pls keep in mind that since it's a time intelligence function, results based on an incontiguous date column may vary in contrast to those based on a standard time table.
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
- v-yingjl5 years agoCommunity Support
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.