Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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

  • Anonymous's avatar
    Anonymous
    4 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) / _min

    Output:

     

    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