Averageif / Average Or for Multiple Conditions in the Same Column

apmale

New Member
Joined
Jul 21, 2009
Messages
18
Hi all,

I'm fairly well versed in functions and array formulas and am surprised that I'm just running into the issue below for the first time. I want to average the data in 'column b' only if the qualifiers 'x' and 'y' are met in 'column a'. For example

Column A Column B
Red 2
Red 4
Yellow 5
Yellow 7
Blue 8
Green 10

I want the average of 'column b' data that corresponds to 'red' and 'yellow'. The answer should be 4.5. I've tried several 'averageif' formulas with 'and' and 'or'. Can seemed to get it right other than a formula that reads: (averageif red + average if yellow) / (counta(if yellow) + counta(if red)). I am thinking that there may be a simpler way, which would be helpful with my more complicated model.

Thanks!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Afraid mine might not be much better



Excel 2003
AB
1Column ACol B
2Red2
3Red4
4Yellow5
5Yellow7
6Blue8
7Green10
8
94.5
Sheet1
Cell Formulas
RangeFormula
B9=SUMPRODUCT(--(A2:A7="Red")--(A2:A7="Yellow"),B2:B7)/(COUNTIF(A2:A7,"Red")+COUNTIF(A2:A7,"Yellow"))
 
Upvote 0
Hi all,

I'm fairly well versed in functions and array formulas and am surprised that I'm just running into the issue below for the first time. I want to average the data in 'column b' only if the qualifiers 'x' and 'y' are met in 'column a'. For example

Column A Column B
Red 2
Red 4
Yellow 5
Yellow 7
Blue 8
Green 10

I want the average of 'column b' data that corresponds to 'red' and 'yellow'. The answer should be 4.5. I've tried several 'averageif' formulas with 'and' and 'or'. Can seemed to get it right other than a formula that reads: (averageif red + average if yellow) / (counta(if yellow) + counta(if red)). I am thinking that there may be a simpler way, which would be helpful with my more complicated model.

Thanks!


Probably not the best way but you can try...

Code:
 =AVERAGE(IF((N2:N7={"Red","Yellow"}),O2:O7))

you'll need to adjust the ranges

Entered with CTRL+SHIFT+ENTER
 
Upvote 0
Hi all,

I'm fairly well versed in functions and array formulas and am surprised that I'm just running into the issue below for the first time. I want to average the data in 'column b' only if the qualifiers 'x' and 'y' are met in 'column a'. For example

Column A Column B
Red 2
Red 4
Yellow 5
Yellow 7
Blue 8
Green 10

I want the average of 'column b' data that corresponds to 'red' and 'yellow'. The answer should be 4.5. I've tried several 'averageif' formulas with 'and' and 'or'. Can seemed to get it right other than a formula that reads: (averageif red + average if yellow) / (counta(if yellow) + counta(if red)). I am thinking that there may be a simpler way, which would be helpful with my more complicated model.

Thanks!

Control+shift+enter,

=AVERAGE(IF(ISNUMBER(MATCH(A2:A7,{"red","yellow"},0)),B2:B7))

With the criterion values in E2:E3...

=AVERAGE(IF(ISNUMBER(MATCH(A2:A7,E2:E3,0)),B2:B7))
 
Upvote 0

Forum statistics

Threads
1,215,403
Messages
6,124,714
Members
449,182
Latest member
mrlanc20

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