Rolling average by week number
I'd like to automate the calculation of a rolling average:
"Average the value of the past four weeks"
"Average the value of the past 12 weeks"
The 'SUP avg' column is what I want to average, and 'W#' is week number.
I know we can get the current week number with =WEEKNUMBER(TODAY())
though I haven't figured out the rolling average
=AVG(COLLECT([SUP avg]:[SUP avg], [W#]:[W#] = WEEKNUMBER(TODAY()) -3, [W#]:[W#] = WEEKNUMBER(TODAY()) -2))
Best Answers
-
Hi Fred,
Try this:
=AVERAGEIF([W#]:[W#], AND(@cell >= WEEKNUMBER(TODAY()) - 3, @cell <= WEEKNUMBER(TODAY())), [SUP Avg]:[SUP Avg])
I used AVERAGEIF because really there's only one criteria... that the date is between 3 weeks ago and today (or 4 weeks, including this week).
First I listed the Week Number range, then with the AND function I stated that within the cell of the W# column, the number needed to be greater than or equal to Today's Weeknumber, minus three... but then we had to say when to STOP the range, which is when it's less than or equal to Today's Weeknumber. At the end I've listed the column to Average.
This can be adapted for 12 weeks by changing the -3 to -11.
Let me know if it works for you!
Cheers,
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
Yes! Thank you so much for this! I knew this could be automated, I just couldn't work out the syntax. Thanks for the formula, and the explanation.
Answers
-
Hi Fred,
Try this:
=AVERAGEIF([W#]:[W#], AND(@cell >= WEEKNUMBER(TODAY()) - 3, @cell <= WEEKNUMBER(TODAY())), [SUP Avg]:[SUP Avg])
I used AVERAGEIF because really there's only one criteria... that the date is between 3 weeks ago and today (or 4 weeks, including this week).
First I listed the Week Number range, then with the AND function I stated that within the cell of the W# column, the number needed to be greater than or equal to Today's Weeknumber, minus three... but then we had to say when to STOP the range, which is when it's less than or equal to Today's Weeknumber. At the end I've listed the column to Average.
This can be adapted for 12 weeks by changing the -3 to -11.
Let me know if it works for you!
Cheers,
Genevieve
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
-
Yes! Thank you so much for this! I knew this could be automated, I just couldn't work out the syntax. Thanks for the formula, and the explanation.
-
Great! So glad this worked for you 🙂
Need more help? 👀 | Help and Learning Center
こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.8K Get Help
- 434 Global Discussions
- 138 Industry Talk
- 470 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 65 Community Job Board
- 486 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!