Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
hwr7dd
Frequent Visitor

Rolling 7 Day Average of a Rolling 7 Day Sum DAX

Hello,
Im calculating the rolling 7 day sum of a field like so:

7 Day Rolling Sum ED Eval =
CALCULATE (
    SUM ( 'Table'[Metric] ),
    FILTER (
        ALLSELECTED ( 'Table'[Date] ),
        'Table'[Date]
            <= MAX ( 'Table'[Metric] )
            && 'Table'[Date]
                >= MAX ( 'Table'[Date] ) - 6
    )
)
This gives me the rolling sum of metric like so 

DateMetricRolling 7 day Sum
4/1/202011
4/2/202012
4/3/202013
4/4/202014
4/5/202015
4/6/202016
4/7/202017
4/8/202017

I would like another column like so:

DateMetricRolling 7 day SumRolling 7 day sum avg
4/1/2020111
4/2/2020121.5
4/3/2020132
4/4/2020142.5
4/5/2020153
4/6/2020163.5
4/7/2020174
4/8/2020174.85

 

I cannot setup the rolling sum measure as a calculated column or something in the dataset as the rolling period needs to be dynamic. 
Any help would be appreciated!

1 ACCEPTED SOLUTION

@hwr7dd , for a week, I usually add these in date tables 

 

new columns
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format

 

measure  like 

Last 7 weeks = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Week Rank])-7 && 'Date'[Week Rank]<=max('Date'[Week Rank])))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

6 REPLIES 6
v-yalanwu-msft
Community Support
Community Support

Hi, @hwr7dd 

 

You could create a measure by the  following:

avg =
AVERAGEX (
    FILTER (
        ALL ( 'Table' ),
        [Date] <= MAX ( 'Table'[Date] )
            && [Date]
                >= MAX ( 'Table'[Date] ) - 6),
    [7 Day Rolling Sum ED Eval])

The final output is shown below:

v-yalanwu-msft_0-1620955129525.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.  

Ashish_Mathur
Super User
Super User

Hi,

In the third column of the second table, you want to create an average from the first of the month to the date of the current row.  Is my understanding correct?  Also, what is the 1 appearing at the end of the 2020?  Furthermore, i do not see a Calendar Table.  You must have a Calendar Table there.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@hwr7dd , Try a measure like this with help from the date table

 

Rolling 7 = CALCULATE(SUM ( 'Table'[Metric] ),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-7,DAY))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Beautiful clean DAX solution - pure as it was intended!

@amitchandak That gives me daily. Im trying to get Week over Week Rolling Average

@hwr7dd , for a week, I usually add these in date tables 

 

new columns
Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format

 

measure  like 

Last 7 weeks = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Week Rank])-7 && 'Date'[Week Rank]<=max('Date'[Week Rank])))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.