Forum Discussion

igibson's avatar
igibson
Frequent Visitor
8 years ago
Solved

Last Year Sales Data is Off By One Week

I have a matrix to compare the sales of the past week (week 37) and the same week last year as such:  PY_SalesAmt = CALCULATE(sum(Sales[NetAmount]),DC03_Calendar[Fin_Year] = "2017") The problem I a...
  • v-jiascu-msft's avatar
    8 years ago

    Hi igibson,

     

    According to my test, DATAADD and SAMEPERIODLASTYEAR both have a granularity of DAY. Maybe we have to get the same week by ourselves if you want the exact same week (same week number). 

    CouldbeRight =
    VAR currentWeeknum =
        MIN ( 'Date'[Weeknum] )
    VAR currentYear =
        YEAR ( MIN ( 'Date'[Date] ) )
    RETURN
        CALCULATE (
            FIRSTDATE ( 'Date'[Date] ),
            FILTER (
                ALL ( 'Date' ),
                'Date'[Weeknum] = currentWeeknum
                    && YEAR ( 'Date'[Date] )
                        = currentYear - 1
            )
        )

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    As we can see from the picture, the first day of week 52 of 2010 is 12/19/2010, not 12/18/2010.

     

     

    Best Regards!

    Dale

  • igibson's avatar
    8 years ago

    A very simple soultion that I implemented was a change in the calendar. I simply used Fin_Week = WEEKNUM(DC03_Calendar[Date]+1,21).