Forum Discussion

tbruce's avatar
tbruce
Regular Visitor
7 years ago
Solved

Year over year comparison

I am new to PowerBI.  I am trying to add a column to a table that provides the value for the same row, but LY.   The data is weekly with a week number in a custom format that include the year -- YY...
  • edhans's avatar
    7 years ago

    The right way to do this is create a date table, then add a date column to your data in Power Query. This old post will help with that since you only have week and year.

     

    Once you've done that, the SAMEPERIODLASTYEAR() function will return the dates you need. So, say your sales is the [Total Sales] measure.

     

    Sales Last Year =
    CALCULATE ( 
         [Total Sales], 
         SAMEPERIODLASTYEAR ( Dates[Date] )
    )

    Would return sales for last year in the same context as your visual. So if your visual is showing a full year, it will be the full LY data. If it is by quarter, week, or day, it will still be the samething for last year.