Average Ifs

jamescooper

Well-known Member
Joined
Sep 8, 2014
Messages
840
Hello,
I have the following formula which takes the average of the first 5 values of a column, how would I add in so it ensures column A2:A5000 = 1, or 2, or 3, too?

=AVERAGE(IF(ROW(P2:P5000<=SMALL(IF(P2:P5000<>"",ROW(P2:P5000)),MIN(COUNT(P2:P5000),5)),IF(P2:P5000<>"",P2:P5000)))

Many thanks.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Control+shuft+enter:

1.

=AVERAGE(IF(ROW(P2:P5000)<=SMALL(IF(ISNUMBER(P2:P5000),ROW(P2:P5000)),MIN(COUNT(P2:P5000),5)),IF(ISNUMBER(P2:P5000),P2:P5000)))

2.

=AVERAGE(IF(ROW(P2:P5000)<=SMALL(IF(ISNUMBER(P2:P5000),IF(A2:A5000=1,ROW(P2:P5000))),MIN(SUM(IF(A2:A5000=1,IF(ISNUMBER(P2:P5000),1))),5)),IF(A2:A5000=1,IF(ISNUMBER(P2:P5000),P2:P5000))))
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,335
Members
452,636
Latest member
laura12345

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