Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Measure displaying last week sum

What would be the easiest way to create a measure which calculates the sum of a metric for the last week? 
  • edhans's avatar
    8 years ago

    As long as you have a date table, there are probably 10 different ways to do this. One such way is this function:

    Last Week Sales = 
    CALCULATE(
        [Total Sales],
        DATESINPERIOD('Calendar'[Date],TODAY(),-7,DAY)
    )

    If you wanted the last calendar week, then you'd need the week number in your date table (the WEEKNUM() function will do this, or you could generate in Power Query with Date.WeekOfYear([Date]), but then use this function:


    Last Calendar Week Sales = 
    CALCULATE(
        [Total Sales],
        'Calendar'[Week Number] = WEEKNUM(TODAY(),1) -1
    )