Forum Discussion

ConstMoss's avatar
ConstMoss
Helper I
8 years ago
Solved

same week last year

our week starts mon and ends sunday. when looking at sales and comparing with last year, how do we get the right dates? 

for example, if i want to compare this week (10/23/2017 to 10/29/2017) with last week (10/24/2016 to 10/30/2016).

 

i tried using SAMEPERIODLASYYEAR but goes back exactly one year and doesn't consider the right dates.

  • Vvelarde's avatar
    Vvelarde
    8 years ago

    ConstMoss

     

    Hi, try with a measure like this:

     

    VentasLY-SameWeek =
    CALCULATE (
        SUM ( Ventas[Ventas] ),
        FILTER (
            ALL ( Calendario ),
            Calendario[Año]
                = SELECTEDVALUE ( Calendario[Año] ) - 1
                && Calendario[Semana] = SELECTEDVALUE ( Calendario[Semana] )
        )
    )

    I use a calendar table with year and week columns. (Calendario)

     

    Regards

     

    Victor

    Lima - Peru

4 Replies

  • Hi I think you will need to use the week function to get the number of the week and use it so seggregate the data.

    • ConstMoss's avatar
      ConstMoss
      Helper I

      thanks, I can get the week number but i how do i go back  and pull the numbers for the week number last year?

      • Vvelarde's avatar
        Vvelarde
        Community Champion

        ConstMoss

         

        Hi, try with a measure like this:

         

        VentasLY-SameWeek =
        CALCULATE (
            SUM ( Ventas[Ventas] ),
            FILTER (
                ALL ( Calendario ),
                Calendario[Año]
                    = SELECTEDVALUE ( Calendario[Año] ) - 1
                    && Calendario[Semana] = SELECTEDVALUE ( Calendario[Semana] )
            )
        )

        I use a calendar table with year and week columns. (Calendario)

         

        Regards

         

        Victor

        Lima - Peru

  • Hi ConstMoss,

     

    October 23, 2017 is week number 43.  October 24, 2016 is week number 44.  So how does one determine the same week last year?