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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
JNelson
Helper II
Helper II

Rolling Average 12 Months

Hello,

 

I see a lot of questions on here about the rolling average however I cannot get any of them to work for my problem. I need a rolling 12 month average that is not affected by the slicer control (ie. not to reset at the start of the filtered table).

 

I need to SUM the last 12 months of [N2 Component] and Divide by the SUM of the last 12 months of [Total Sold]. To create a rolling 12 month average. I need it to go further than the selected dates in the slicer. Ie. Not to restart at July 2022, the July number should be July 2022 - Aug 2021. And should be blank if there is no data in the N2 or Total Sold

 

I have a separate Date Table. Unfortunately I cannot upload a sample of my files, only images - apologies! I hope someone can help, I feel like this is very simple, just can't get my head around it. 

 

TIA 🙂

 

Rolling Avg.jpg

 

1 ACCEPTED SOLUTION
5 REPLIES 5
miTutorials
Super User
Super User
pratyashasamal
Super User
Super User

Hi @JNelson ,
You can try out this example :-

Here are the steps you can follow:

1. Create measure.

Sum =
var _1=
IF(MAX([month])<>12,
CALCULATE(MAX('Table'[Month-Year]),FILTER(ALL('Table'),'Table'[Year]=MAX('Table'[Year])-1&&'Table'[month]=MAX('Table'[month])+1)),
DATE(YEAR(MAX([Month-Year])),1,1))

var _2=
CALCULATE(
    SUM('Table'[Value]),
    FILTER(ALL('Table'),[Month-Year]>=_1&&[Month-Year]<=MAX([Month-Year])))
    return _2
Sum/12 =
var _1=
IF(MAX([month])<>12,
CALCULATE(MAX('Table'[Month-Year]),FILTER(ALL('Table'),'Table'[Year]=MAX('Table'[Year])-1&&'Table'[month]=MAX('Table'[month])+1)),
DATE(YEAR(MAX([Month-Year])),1,1))

var _2=
CALCULATE(
    SUM('Table'[Value]),
    FILTER(ALL('Table'),[Month-Year]>=_1&&[Month-Year]<=MAX([Month-Year]))) 
    return _2/12

Thanks ,
Pratyasha Samal
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Hi @pratyashasamal 

 

Can you please describe how the calendar table should look? I'm a bit confused with the [Month] [Month-Year] [Year] measures you're referring to? Should I split my date column out into those three?

 

Thanks

Hi @JNelson ,
Yes you can add 3 columns .
You can refer to this link for more info regarding calender table in power bi :-
https://hevodata.com/learn/power-bi-calendar-table/

Thanks ,
Pratyasha Samal
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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