an average with a dynamic range (which excludes blank)

akardar1

New Member
Joined
Dec 22, 2010
Messages
23
Hi Wizards,

I have a column T with values like:

5
6
7
blank
9
7
blank
12
15

I would like an average of the last 5 values... but excluding blanks!
So... if I am at the bottom of the the list.... I want an average of 15,12,7,9 and 7.

If I use a simple =average of 5 value, it would be 15,12, blank, 7, 9
... which is not good because i want 5 numeric values for my average, i don't want the blank
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Use this and Press CTRL+SHIFT+ENTER
Excel Formula:
=AVERAGE(LOOKUP(LARGE(IF(ISNUMBER(A4:A16),ROW(A4:A16)),{1,2,3,4,5}),ROW(A4:A16), A4:A16))
 
Upvote 0
If i wanted to look a at the last "30 non-blank values", instead of 5, do I need to
change {1,2,3,4,5}
to {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,19,30}
?
 
Upvote 0
I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Another alternative that does not require the Ctrl+Shift+Enter confirmation - & just change W1 to get 30 if that is what you want (provided there are at least 30 numbers in the range. ;))

20 12 20.xlsm
TUVW
15No. to average5
26Average10
37
4
59
67
7
812
915
10
Average Last N
Cell Formulas
RangeFormula
W2W2=AVERAGE(INDEX(T:T,AGGREGATE(14,6,ROW(T1:T1000)/(T1:T1000<>""),W1)):T1000)
 
Upvote 0

Forum statistics

Threads
1,215,008
Messages
6,122,672
Members
449,091
Latest member
peppernaut

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