Calculation of Average of last 3 non #N/A values

Kutkan

New Member
Joined
Mar 4, 2011
Messages
4
Values Average Last 3 non #n/a

12
14
13 13
11 13
45 23
#N/A 23
44 33
13 34
41 33
#N/A 33
33 29
22 32
#N/A 32
45 33

Is there a way to do this automatically with a function?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Values Average Last 3 non #n/a

12
14
13 13
11 13
45 23
#N/A 23
44 33
13 34
41 33
#N/A 33
33 29
22 32
#N/A 32
45 33

Is there a way to do this automatically with a function?

Let A2:A15 house the sample you provided.

B2, control+shift+enter, not just enter, and copy down:
Code:
=IF(COUNT($A$2:A2)>=3,AVERAGE(IF(ROW($A$2:A2)>=
    LARGE(IF(ISNUMBER($A$2:A2),ROW($A$2:A2)),3),
      IF(ISNUMBER($A$2:A2),$A$2:A2))),"")
 
Upvote 0
Many thanks Alaaddin.

Working further that night I came with a solution, but it is more convoluted than yours. Does not work with the first 2 cells where you do not have 3 values

When you let A2:A15 have the values

B4, control+shift+enter, and copy down:

=AVERAGE(LOOKUP(LARGE((ROW(INDIRECT(1&":"&COUNTA($A$2:$A4))))*NOT(ISNA($A$2:$A4));{1;2;3});ROW(INDIRECT(1&":"&COUNTA($A$2:$A4)));$A$2:$A4))
 
Upvote 0
Many thanks Alaaddin.

You are welcome.

Working further that night I came with a solution, but it is more convoluted than yours. Does not work with the first 2 cells where you do not have 3 values

When you let A2:A15 have the values

B4, control+shift+enter, and copy down:

=AVERAGE(LOOKUP(LARGE((ROW(INDIRECT(1&":"&COUNTA($A$2:$A4))))*NOT(ISNA($A$2:$A4));{1;2;3});ROW(INDIRECT(1&":"&COUNTA($A$2:$A4)));$A$2:$A4))

Looks expensive too.
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,219
Members
452,895
Latest member
BILLING GUY

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