Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 350
  • Last Modified:

AVERAGEIF

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.
0
tora111
Asked:
tora111
  • 4
  • 3
1 Solution
 
Saqib Husain, SyedEngineerCommented:
=AVERAGEIF(B:B,"aa",A:A)+AVERAGEIF(C:C,"aa",A:A)
0
 
barry houdiniCommented:
...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
0
 
tora111Author 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?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
barry houdiniCommented:
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
0
 
tora111Author Commented:
ssaqibh,

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

It's not = 3
0
 
barry houdiniCommented:
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
0
 
tora111Author 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?
0
 
barry houdiniCommented:
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
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now