Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Total Sales Variation Same Period Last Year

Hello,   My data model has sales data from the last 3 years. I'm trying to build a report with two charts (image below): Sales variation by month. Variation related to last month. (OK) Sales var...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Anonymous 

    To get the both last year value with slicer, you would need to create a distinct year table as the slicer.

     

    1. Create a new table:

    Slicer table = Distinct(Calendar[Year])


    2. Create the 3 measures:

    Total Sales = SUMX( Sales, Sales[Total])

     

    Total Sales Same Period Last Year =  CALCULATE([Total Sales], FILTER('Calendar',  'Calendar'[Year]=SELECTEDVALUE('Slicer table'[Year])-1),SAMEPERIODLASTYEAR('Calendar'[Data]))

     

    Variation Last Year % = divide([Total Sales]-[Total Sales Same Period Last Year],[Total Sales],0)

     

     

    Best regards
    Paul Zheng _ Community Support Team

    If this post helps, please Accept it as the solution to help the other members find it more quickly.