Forum Discussion
Sales analysis vs same period last year
- Anonymous2 years ago
Thank you rajendraongole1
Hi, HY2024
According to your description, I used the following sample data:
I created a calendar table:
The relationship between the calendar table and the sales table is as follows:
First, I created the following DAX expression to find the QTY of the current matrix month:
Current_month_QTY = CALCULATE( SUM(financials[ Sales]), FILTER('Date table', 'Date table'[Year] = MAX('Date table'[Year]) ) )I used the following DAX expression to find the QTY for the same period in the previous year:
LastYearQTY = CALCULATE( SUM(financials[ Sales]), SAMEPERIODLASTYEAR('Date table'[Date]) )I use the following DAX expression to create a PercentageOfLastYearSales measure:
PercentageOfLastYearSales = DIVIDE([Current_month_QTY],[LastYearQTY])The results are as follows:
The reason you are showing 118% all together may be that you are using the ALL function in your DAX expression, which clears all external filters, including the row and column fields placed by your matrix. You can learn about the event intelligence functions in DAX, which will be helpful for you to calculate YTD, QTD, and so on:
Time intelligence functions (DAX) - DAX | Microsoft Learn
I have provided the PBIX file used in this instance below.
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I have tried recreating a new datetable that I marked the table as date table, but when I cxreate columns for month and year, those can only be selected as "text" format
and in my formula I filter this way
but it still doesn't work.
and for the relationships I have linked the sales table with the datetable though a many-to-many relationships
Am I doing something wrong?
can you please help me?
thank you
best regards