Forum Discussion

calimero48's avatar
calimero48
Helper II
8 years ago

Same week previous year

Hi

 

I have create a measure to get the sum of sale from previous year same week as

 

        IF ( HASONEVALUE (DAT[CalendarYear]), CALCULATE (SUM ([CA]),    
                    FILTER (ALL ( DAT),
                            DAT[CalendarYear] = VALUES ( DAT[CalendarYear] ) - 1     && CONTAINS(
                            VALUES ( DAT[WeekNumberOfYear] ),
                            DAT[WeekNumberOfYear],
                            DAT[WeekNumberOfYear] ))),BLANK())

 

This measure works well until we drill down. For exemple, if I want to split to sales to product and in one week of the current year we do not have any sales, the measure do not return any previous sales.

 

What I am doing wrong? Thanks in advance for your helps

 

Regards

 

 

7 Replies

  • Sorry,

     

    I forgot the give the DAT table structure

    CalendarYear Integer  -> Year

    WeekNumberOfYear  -> Integer -> Week number (1 to 53)

    FullAlternateDate -> Date

    MonthNumber Integer -> Month

     

    at least

     

    • calimero48's avatar
      calimero48
      Helper II

      Hi

       

      Thank you for your reply. I start with this article.

       

      Let me explain :

       

      Fact table is

      Date|Vendor|Manager|Article|Value

      2017-01-04|v01|M01|A01|10

      2017-01-11|v02|M01|A01|20

      2017-01-05|v02|M01|A01|10

      2018-01-24|v01|M01|A01|10

      2018-01-12|v02|M01|A01|10

       

       

      With my  measure if i do

      week / Manager/vendor  Previous year same week /Current year week

       

      I got

      W1                  2017         2018

          A01              20             10

                  V01                            ( I do not have sales in 2018 week 1)

                  V01                       10

      W2

          A01               20           10

                  V02       20           10 ( I  have sales in 2018 week 2)

       

       

      What i understand is that my measure for the previous week year is taking only week of the current year having sales.

       

      How to avoid this?

       

      Thanks for your help