Forum Discussion

bo_afk's avatar
bo_afk
Post Patron
7 years ago
Solved

Current week vs last week sum

Hi,   I have a dataset containing week numbers and sales figures associated to each week, along with other columns such as market, product etc.   How would do I create a measure to compare the sa...
  • Anonymous's avatar
    Anonymous
    7 years ago

    Hi bo_afk ,

    You can add allselected function to get current last week number and use it to find out correspond amount:

    CW Sales =
    VAR CW =
        CALCULATE ( MAX ( Table[WeekNum] ), ALLSELECTED ( Table ) )
    RETURN
        CALCULATE (
            SUM ( Table[Sales] ),
            FILTER ( ALLSELECTED ( Table ), Table[WeekNum] = CW )
        )
    

    Regards,

    Xiaoxin Sheng