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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Rolling Average Help!

Hi everyone!

I have been banging my head against the wall with this one for quite some time.  I have found some calculations in the forums that solve similar problems but I cannot for the life of me implement them in my dataset.  

 

My data involves contracts and analyzing those contracts for a renewal percentage.

 

So - the data:

 

Max End Date formula:

 

MaxDate = CALCULATE(MAX(Contracts[End Date]),ALLEXCEPT(Contracts,Contracts[Serial]))

Renewed going forward? = IF([MaxDate]>Contract[End Date],1,0)

Expirations = 1 for all rows as it represents an expiring contract

Renewal Percentage = [Renewed Going Forward?]/[Expirations]

 

SERIALSTART DATEEND DATEMAX END DATERENEWED GOING FORWARD?EXPIRATIONSRENEWAL PERCENTAGE
ABC1/1/20161/1/20171/1/201911100%
ABC1/1/20171/1/20181/1/201911100%
ABC1/1/20181/1/20191/1/2019010%
BCD1/1/20161/1/20171/1/2017010%
CDE1/1/20161/1/20171/1/201811100%
CDE1/1/20171/1/20181/1/2018010%
DEF1/1/20161/1/20171/1/201711100%

 

All of these thrown into a matrix gets me the following:

Capture.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

What I need to add is a rolling average and because of measures I used earlier some of the tips I've found don't apply to what I'm working on.  

 

Thanks in advance for any advice!!

 

Cheers - Tom

1 ACCEPTED SOLUTION
v-caliao-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

To achieve rolling average measure, you need to get the total value, and then use the total value divided by month number. Here is the sample DAX for you referebce.
3 Month Moving Sum Units Sold] =
CALCULATE([Units Sold],
          DATESINPERIOD(Calendar[Date],
                        LASTDATE(Calendar[Date]),-3, Month
                       )
         )


[3 Month Moving Avg Corrected]=

[3 Month Moving Sum Units Sold] /
CALCULATE(DISTINCTCOUNT(Calendar[Year Month]),
          DATESINPERIOD(Calendar[Date],
                        LASTDATE(Calendar[Date]),-3,Month
                       )
         )

 

Reference
https://powerpivotpro.com/2013/07/moving-averages-sums-etc/
http://www.sqlbi.com/articles/rolling-12-months-average-in-dax/

 

Regards,

Charlie Liao

View solution in original post

1 REPLY 1
v-caliao-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

To achieve rolling average measure, you need to get the total value, and then use the total value divided by month number. Here is the sample DAX for you referebce.
3 Month Moving Sum Units Sold] =
CALCULATE([Units Sold],
          DATESINPERIOD(Calendar[Date],
                        LASTDATE(Calendar[Date]),-3, Month
                       )
         )


[3 Month Moving Avg Corrected]=

[3 Month Moving Sum Units Sold] /
CALCULATE(DISTINCTCOUNT(Calendar[Year Month]),
          DATESINPERIOD(Calendar[Date],
                        LASTDATE(Calendar[Date]),-3,Month
                       )
         )

 

Reference
https://powerpivotpro.com/2013/07/moving-averages-sums-etc/
http://www.sqlbi.com/articles/rolling-12-months-average-in-dax/

 

Regards,

Charlie Liao

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.