Calculate average using multiple criteria. (averageifs or something else?)

VGPOP

Board Regular
Joined
Jun 13, 2007
Messages
68
Hello everyone,

I would like to see what formula to use to calculate average of last entries based on two conditions:

For example:

C12 = R
C13 = H
C14 = R
C15 = R
C16 = H
C17 = H
C18 = H
C19 = R
...
...
C173 = R

D12 = 5
D13 = 6
D14 = 0
D15 = 1
D16 = 9
D17 = 0
D18 = 11
D19 = 6
...
...
D173 = 3


J12 = Mark
J13 = Johnson
J14 = Peter
J15 = Bob
J16 = Johnson
J17 = Johnson
J18 = Peter
J19 = Mark
...
...
J173 = Mark

In the first row (row 12) to make it clear, Mark was on the road and had 5 points.

I want a formula that calculate the average of the "last three entries", let's say, "Johnson" had when he was on the road ("R")

I have excel 2007, and I dont know of averageifs will work.

I'd appreciate any help.

Thanks.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Try this "array formula"

=AVERAGE(IF(C12:C173="R",IF(J12:J173="Johnson",IF(ROW(D12:D173)>=LARGE(IF(C12:C173="R",IF(J12:J173="Johnson",ROW(D12:D173))),3),D12:D173))))

confirmed with CTRL+SHIFT+ENTER

Assumes there will be at least 3 rows that meet the criteria.....if not then you'll get an error....or edit like this to return a message

=IFERROR(AVERAGE(IF(C12:C173="R",IF(J12:J173="Johnson",IF(ROW(D12:D173)>=LARGE(IF(C12:C173="R",IF(J12:J173="Johnson",ROW(D12:D173))),3),D12:D173)))),"Less than 3 matches")
 
Upvote 0
Try this "array formula"

=AVERAGE(IF(C12:C173="R",IF(J12:J173="Johnson",IF(ROW(D12:D173)>=LARGE(IF(C12:C173="R",IF(J12:J173="Johnson",ROW(D12:D173))),3),D12:D173))))

confirmed with CTRL+SHIFT+ENTER

Assumes there will be at least 3 rows that meet the criteria.....if not then you'll get an error....or edit like this to return a message

=IFERROR(AVERAGE(IF(C12:C173="R",IF(J12:J173="Johnson",IF(ROW(D12:D173)>=LARGE(IF(C12:C173="R",IF(J12:J173="Johnson",ROW(D12:D173))),3),D12:D173)))),"Less than 3 matches")

Beautiful. It does work!

Thanks.

I was trying to use sumproduct, like combined all three requests, but couldnt come up with correct answer.

Thanks again!.

:)
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,777
Members
452,942
Latest member
VijayNewtoExcel

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