Forum Discussion
ajve22
3 years agoFrequent Visitor
Previous Year Sales
Hi,
I am trying to calculate last year sales using minimum line of dax code as below:
Sales Last Year = CALCULATE( [Sales] , PREVIOUSYEAR('Date (Sales Order)'[Order Date] ) )
It gives correct value when use this on matrix visual along with the year and month on rows but gives blank when using it on the card visual.
So, I need to show the previous year sales on matrix visual using year and motnhs on rows which can diplay previous year sales for all the years and on the card viusal it should show just the last year sales.
Please suggest how to achieve this using minimun lines of dax code, so it can show value on card visual also.
Thanks
5 Replies
- bhelou
Responsive Resident
Dear ,
Check this dax if it fits with you ,
Sales Last Year = CALCULATE(
[Sales],
FILTER(
ALL('Date (Sales Order)'),
'Date (Sales Order)'[Order Date] = MAX('Date (Sales Order)'[Order Date]) - 365
)
)
Change the table Name of the dates accordingly
Please consider accepting this as a solution !! Respect your KUDO !!
I appreciate your recognition and feel proud to have been able to assist you. - Syndicate_Admin
Administrator
Dear, this would be the measure to create:
Sales Previous Year = CALCULATE([Sum Sales],DATEADD(Calendar[Date],-1,YEAR))So you can get the sales of the previous year.- ajve22Frequent Visitor
Syndicate_Admin It shows the total sales amount when place on a card visual. I need to show only last year sales when place on a card visual.