Forum Discussion
Last year comparison
Hi team,
How can we compare year on year sales as per user selection. I mean we have multiple Dax formulas when in we can compare the sales from current year to previous years. But I just want to implement the functionality when in user can compare on multiple years as per slicer's multiple selection.
Thanks
- Anonymous4 years ago
Hi Anonymous ,
According to my understanding, you want to get the comparison(%) between selected years in slicer, right?
If so , please firstly create a Year table for slicer:
Year Slicer = DISTINCT( SELECTCOLUMNS('Table',"Year",YEAR([Date])))And then create a measure:
comparison(%) = var _min= CALCULATE(SUM('Table'[Value]),FILTER('Table',YEAR([Date])=MIN('Year Slicer'[Year]))) var _max=CALCULATE(SUM('Table'[Value]),FILTER('Table',YEAR([Date])=MAX('Year Slicer'[Year]))) return (_max -_min) / _minOutput:
If it isn't your expected , please share more detail information to help us clarify your scenario.You could kindly refer to:
How to Get Your Question Answered Quickly - Microsoft Power BI Community
How to provide sample data in the Power BI Forum - Microsoft Power BI Community
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- truptisCommunity Champion
Hi Anonymous ,
I found a similar thing on this post:
https://community.powerbi.com/t5/Desktop/Select-multiple-values-from-slicer-for-DAX-formula/m-p/500983#M233774 - AnonymousNot applicable
Hi Anonymous ,
According to my understanding, you want to get the comparison(%) between selected years in slicer, right?
If so , please firstly create a Year table for slicer:
Year Slicer = DISTINCT( SELECTCOLUMNS('Table',"Year",YEAR([Date])))And then create a measure:
comparison(%) = var _min= CALCULATE(SUM('Table'[Value]),FILTER('Table',YEAR([Date])=MIN('Year Slicer'[Year]))) var _max=CALCULATE(SUM('Table'[Value]),FILTER('Table',YEAR([Date])=MAX('Year Slicer'[Year]))) return (_max -_min) / _minOutput:
If it isn't your expected , please share more detail information to help us clarify your scenario.You could kindly refer to:
How to Get Your Question Answered Quickly - Microsoft Power BI Community
How to provide sample data in the Power BI Forum - Microsoft Power BI Community
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.