Forum Discussion

kent_iglehart's avatar
kent_iglehart
New Member
6 years ago
Solved

Help calculating a 7 day running total column

I have a table in PowerBI that has the column "Date" and "Sales". I want to create a measure and display it in a table that computes a rolling 7 day total of the "Sales" column. To be clear, I want to see this over time, I do not want it for a single day, I want to create a table exactly like I am showing below, thanks!

 

DateSalesRunning 7 Day Total
1/1/202072 
1/2/20205 
1/3/202034 
1/4/202045 
1/5/202081 
1/6/202060 
1/7/202063360
1/8/20206294
1/9/202053342
1/10/202030338
1/11/202032325
1/12/202035279
1/13/202082301
1/14/202055293
1/15/202099386
1/16/202097430
1/17/2020100500
1/18/202054522
  • Hi,

    Assuming there is a sale recorded for everyday, try this:

    1. Create a Calendar Table
    2. Build a relationship from the Date column of the Data Table to the Date column of the Calendar Table
    3. To your visual, drag the Date field from the Calendar Table
    4. Write these measures

    Total sales = SUM(Data[Sales])

    7 days rolling sales = CALCULATE([Totalsales],DATESBETWEEN(Calendar[Date],MIN(Calendar[Date])-6,MIN(Calendar[Date])))

    Hope this helps.

5 Replies