Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
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]
| SERIAL | START DATE | END DATE | MAX END DATE | RENEWED GOING FORWARD? | EXPIRATIONS | RENEWAL PERCENTAGE |
| ABC | 1/1/2016 | 1/1/2017 | 1/1/2019 | 1 | 1 | 100% |
| ABC | 1/1/2017 | 1/1/2018 | 1/1/2019 | 1 | 1 | 100% |
| ABC | 1/1/2018 | 1/1/2019 | 1/1/2019 | 0 | 1 | 0% |
| BCD | 1/1/2016 | 1/1/2017 | 1/1/2017 | 0 | 1 | 0% |
| CDE | 1/1/2016 | 1/1/2017 | 1/1/2018 | 1 | 1 | 100% |
| CDE | 1/1/2017 | 1/1/2018 | 1/1/2018 | 0 | 1 | 0% |
| DEF | 1/1/2016 | 1/1/2017 | 1/1/2017 | 1 | 1 | 100% |
All of these thrown into a matrix gets me the following:
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
Solved! Go to Solution.
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
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
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 45 | |
| 41 | |
| 20 | |
| 17 |
| User | Count |
|---|---|
| 69 | |
| 64 | |
| 32 | |
| 31 | |
| 27 |