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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Super User
Super User

@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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@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!:
Power BI Cookbook Third Edition (Color)

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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