We help IT Professionals succeed at work.

AVERAGEIF

tora111
tora111 asked
on
Can I do averageif like below?

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

(1+3+5)/3 = 3

If not, what can I do?

Thanks a lot.
Comment
Watch Question

CERTIFIED EXPERT

Commented:
=AVERAGEIF(B:B,"aa",A:A)+AVERAGEIF(C:C,"aa",A:A)
CERTIFIED EXPERT
Most Valuable Expert 2013

Commented:
...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

Author

Commented:
AVERAGEIF
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?
CERTIFIED EXPERT
Most Valuable Expert 2013

Commented:
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

Author

Commented:
ssaqibh,

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

It's not = 3
CERTIFIED EXPERT
Most Valuable Expert 2013
Commented:
For your revised requirement try this version

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

still confirmed with CTRL+SHIFT+ENTER

regards, barry

Author

Commented:
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?
CERTIFIED EXPERT
Most Valuable Expert 2013

Commented:
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

Explore More ContentExplore courses, solutions, and other research materials related to this topic.