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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
OhLookAnError
Helper I
Helper I

Calculating a rolling 7 day and 30 day average for Revenue per hour worked

Ive seen a lot of talk on rolling averages and have learned a lot from the reading but I cant seem to get this one to work. 

 

I need to calculate: trailing 7 day average revenue per hour worked and trailing 30 day average revenue per hour worked. 

 

I have tried two different Measures but they are both returning the same values for 7 day and 30 day. they also dont seem to be averaging either because on days that rvenue is not yet reported its returning $0 which i wouldnt think it would do if it was actually returning an average. Here are the two measures I have tried so far:

 

T30D RPHW $'s = Calculate(
                 AVERAGEX(
                   VALUES(tblName[ReportDate]),
                          [Avg Revenue]),
            DATESINPERIOD(tblName[ReportDate], MAX(tblName[ReportDate]),-30,Day))
 
For the Above Measure, the [Avg Revenue] measure is:
Avg Revenue =
    Var TotalHours = SUM(tblName[TotalHrs])
    Var Revenue = SUM(tblName[Revenue])
Return
Divide(Revenue,TotalHours,0)
 
 
 
The first measure I tried was:
 
T30D RPHW $'s =
    Var Hours = Calculate(SUM(tblName[TotalHrs]),
                DATESINPERIOD(tblName[ReportDate],
                LASTDATE(tblName[ReportDate]),-30,DAY))
    VAR Revenue = Calculate(SUM(tblName[Revenue]),
                DATESINPERIOD(tblName[ReportDate],
                LASTDATE(tblName[ReportDate]),-30,DAY))
RETURN
Divide(Revenue,Hours,0)
 
I  have been succesful with similar measures in the past but only where theres one value per day. Here, I need [Revenue] divided by [TotalHours] per day then I need the trailing 30 & 7 day averages so I think theres a layer there that I just havent quite wrapped my head around yet. 
 
Thanks in advance for any help! 
1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@OhLookAnError You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...

 

Also, specifically this video should help:

 

Otherwise, really need sample data to be super specific.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@OhLookAnError You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...

 

Also, specifically this video should help:

 

Otherwise, really need sample data to be super specific.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks Greg, the entire issue turned out to be that my table with hours & revenue wasnt connected to my power query calendar in the data model. as soon as I connected it the measures worked as intended!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.