Forum Discussion

Jos13's avatar
Jos13
Helper III
6 years ago
Solved

Week over Week Sales Growth

Hi Team,

I have a data set in the following format.

 

I have created a measure to calculate daily growth as follows

Daily growth% =
    VAR __PREV_day = CALCULATE([Sales], DATEADD('DateTable'[Date], -1, DAY))
    RETURN
        DIVIDE([Sales] - __PREV_day, __PREV_day)
 
I am not able to find weekly growth using the above method since week is not supported in DATEADD. Please help me on this.
 
Best Regards,
Jos
  • Anonymous's avatar
    Anonymous
    6 years ago

    HI Jos13,

    You can try to use following link if it meets your requirement:

    Weekly growth% =
    VAR currDate =
        MAX ( 'DateTable'[Date] )
    VAR _curr =
        CALCULATE (
            SUM ( Table[Sales] ),
            FILTER (
                ALLSELECTED ( Table ),
                YEAR ( [Date] ) = YEAR ( currDate )
                    && WEEKNUM ( [Date] ) = WEEKNUM ( currDate )
            )
        )
    VAR _prev =
        CALCULATE (
            SUM ( Table[Sales] ),
            FILTER (
                ALLSELECTED ( Table ),
                IF (
                    WEEKNUM ( currDate ) > 1,
                    YEAR ( [Date] ) = YEAR ( currDate )
                        && WEEKNUM ( [Date] ) = WEEKNUM ( currDate ),
                    YEAR ( [Date] )
                        = YEAR ( currDate ) - 1
                        && WEEKNUM ( [Date] )
                            = WEEKNUM ( DATE ( YEAR ( currDate ) - 1, 12, 31 ) )
                )
            )
        )
    RETURN
        DIVIDE ( _curr - _prev, _prev )
    

    Regards,

    Xiaoxin Sheng

4 Replies