Moving Average

cunningAce

Board Regular
Joined
Dec 21, 2017
Messages
91
Office Version
  1. 365
Platform
  1. Windows
Hi All,

Looking for a little help with the following please,

I want to find the average according to the variable in the "Average Weeks" cell.

So in this example it would look at the last 3 weeks figures, Weeks 4 - 6 and work out the average = 9243

As in the example, the future cells Week 7, 8 9 10.... will contain zeros, and I don't want the average to be affected by this.

Thanks in advance for your help


Book1
ABCDEFGHIJ
1
2Week 1Week 2Week 3Week 4Week 5Week 6Week 7Week 8Week 9Week 10
389971204710645105331019570000000
4
5Average Weeks3
6Average9243
7
Sheet1
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
In C6 control+shift+enter, not just enter:

=AVERAGE(OFFSET(INDEX(B3:K3,MATCH(9.99999999999999E+307,1/(B3:K3))),0,0,1,-3))
 
Upvote 0
Thanks for this, Seems to work well.

Would you mind explaining what this part of the formula is doing?

MATCH(9.99999999999999E+307,1/(B3:K3)
 
Upvote 0
Thanks for this, Seems to work well.

Would you mind explaining what this part of the formula is doing?

MATCH(9.99999999999999E+307,1/(B3:K3)

1. MATCH ignore error values when they occur among non-error values: For example, in #N/A,1,0.2,#DIV/0! the errors are skipped.

2. MATCH (and kindred functions like LOOKUP, etc.) land on the last numeric value in a range when they are given 9.99999999999999E+307 as a look up value. This big number is an Excel constant, indicating a limit value.

3. The expression 1/(B3:K3) evaluates to decimal values for non-zero nimbers and #DIV/0! errors for 0 values, etc., from which MATCH picks out the position of the last decimal value and returns the correlated value fom B3:K3. INDEX gives the address of that value to the OFFSET function for further processing.

Hope this helps.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top