Forum Discussion

shep123's avatar
shep123
Helper I
9 years ago
Solved

Running 7 Day Total

I am trying to have a running total for the last 7 days. My table currently have Date and Value. I inserted a calculate column that I want to calculate the results for the previous 7 days. Since my table starts at 1/1 there will naturally be less than 7 days for the first 6 days of the year. However, beyond that I want to calculate the previous 7 day total based on only dates that fall in that range. So 1/7 would be all the values for 1/1 through 1/7 and 1/8 would be all the values for 1/2 through 1/8 and continuing on for the entire year. How can I accomplish this in DAX?

 

Date   Value   Running 7 Day

1/1      2           2

1/2      3           5

1/3      1           6

1/4      4           10

1/5      2           12

1/6      3           15

1/7      1           16

1/8      4           18

1/9      3           18

 

 

  • Use this MEASURE

     

    7 Day RT MEASURE =
        CALCULATE (
            SUM ( Table1[Value] ),
            DATESINPERIOD ( Table1[Date], LASTDATE ( Table1[Date] ), -7, DAY )
        )

1 Reply

  • Sean's avatar
    Sean
    Community Champion

    Use this MEASURE

     

    7 Day RT MEASURE =
        CALCULATE (
            SUM ( Table1[Value] ),
            DATESINPERIOD ( Table1[Date], LASTDATE ( Table1[Date] ), -7, DAY )
        )