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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply

Average 12 months rolling without blanks

Hi all, 

 

I am looking for some assistance in DAX.  I need to calculate the 12 months rolling average by client base on the numbers of time they have purchased from us. 

I have come up with this formula that works ok for clients with consistent purchases throughout the 12 months window. But, the average gets off for clients who have only purchased once, twice, etc within those 12 months, as it divides the total number of invoices in 12 instead of doing only for the number of months that particular client purchased from us. 

I have attached the table showing what I mean. 

=
IF (
AND (
[# Invoices] > 0,
MAX ( Dates_Table[Date] )
> CALCULATE ( MIN ( Dates_Table[Date] ), ALL ( Dates_Table[Date] ) )
),
CALCULATE (
[# Invoices],
DATESINPERIOD ( Dates_Table[Date], LASTDATE ( Dates_Table[Date] ), -1, YEAR )
)
) /
CALCULATE([# Months],
FILTER( Dates_Table,
DATESINPERIOD (Dates_Table[Date], LASTDATE ( Dates_Table[Date] ), -1, YEAR )),
[# Invoices] > 0
)

DAX Assistance.JPG

 

Thanks in advance for your help. 

 

Oscar 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

First, Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Second, 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...



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

1 REPLY 1
Greg_Deckler
Community Champion
Community Champion

First, Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Second, 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...



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...

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.