Forum Discussion
Dynamic year comparization
- Anonymous4 years ago
Hi Anonymous
I created a sample with some relatively simple data , hope it will help you .
Original data :
(1)Create a new table with [Date] from original table and display with year .Then add the new column in a slicer to filter data in original table.
Date = SUMMARIZECOLUMNS('Table'[Date].[Year])(3)Create two measures to return the total sales from current year and previous year through the specified year in slicer .
current year total sales = CALCULATE(SUM('Table'[value]),FILTER('Table',YEAR('Table'[Date])=SELECTEDVALUE('Date'[Year])))previos year total sales = CALCULATE(SUM('Table'[value]),FILTER('Table',YEAR('Table'[Date])=SELECTEDVALUE('Date'[Year])-1))The final result is as shown :
I have attached my pbix file , you can refer to it .
Best Regard
Community Support Team _ Ailsa Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous
I created a sample with some relatively simple data , hope it will help you .
Original data :
(1)Create a new table with [Date] from original table and display with year .Then add the new column in a slicer to filter data in original table.
Date = SUMMARIZECOLUMNS('Table'[Date].[Year])
(3)Create two measures to return the total sales from current year and previous year through the specified year in slicer .
current year total sales = CALCULATE(SUM('Table'[value]),FILTER('Table',YEAR('Table'[Date])=SELECTEDVALUE('Date'[Year])))previos year total sales = CALCULATE(SUM('Table'[value]),FILTER('Table',YEAR('Table'[Date])=SELECTEDVALUE('Date'[Year])-1))
The final result is as shown :
I have attached my pbix file , you can refer to it .
Best Regard
Community Support Team _ Ailsa Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.