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 t...
  • Ashish_Mathur's avatar
    6 years ago

    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.