Link to home
Start Free TrialLog in
Avatar of tora111
tora111

asked on

AVERAGEIF

Can I do averageif like below?

User generated image
=AVERAGEIF(B:C,"aa",A:A)

(1+3+5)/3 = 3

If not, what can I do?

Thanks a lot.
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

=AVERAGEIF(B:B,"aa",A:A)+AVERAGEIF(C:C,"aa",A:A)
...Hey Saqib!.....but won't that give you 1+4 = 5?

To get the average overall try an array formula e.g.

=AVERAGE(IF(B1:C5="aa",A1:A5))

confirmed with CTRL+SHIFT+ENTER

regards, barry
Avatar of tora111
tora111

ASKER

User generated image
Sorry I forgot to mention that if b and c are same then count as 1

Still = (1+3+5)/3 = 3 ?

Is it possible?
I forgot to say why your initial AVERAGEIF function doesn't work - AVERAGEIF works on a 1 cell to 1 cell basis so even though you only used A:A as the range to average your average range is actually 2 columns so when C3 is "aa" the formula is trying to add B3 (not A3) to the average (and because that's text it's ignored)

See workbook attached

regards, barry
averages.xls
Avatar of tora111

ASKER

ssaqibh,

=AVERAGEIF(B:B,"aa",A:A)+AVERAGEIF(C:C,"aa",A:A)  = 5

It's not = 3
ASKER CERTIFIED SOLUTION
Avatar of barry houdini
barry houdini
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tora111

ASKER

Hi Barry,

So I must separate each columns (b, c). If I have more columns, then I need to add it 1 by 1, right?
For a small number of columns I would do it as per my suggestion, testing each column individually.....but if you have a large number of columns there are ways that don't involve splitting them all out, e.g. to average A1:A5 as before but based on data in B1:Z5 try this formula

=AVERAGE(IF(MMULT((B1:Z5="aa")+0,TRANSPOSE(COLUMN(B1:Z5)^0)),A1:A5))

confirmed with CTRL+SHIFT+ENTER

regards, barry