average and if

G

Guest

I have a column of dollar amounts and a column of categories. I want to
average all cells in the dollar amount column that equal a certain text. For
instance, I want the average of a range of cells in Col A if Col B = HOTEL.
This seems like it should be simple, but it is eluding me.
 
J

JE McGimpsey

One way:

Array-entered (CTRL-SHIFT-ENTER or CMD-RETURN):

=AVERAGE(IF(B1:B100="HOTEL",A1:A100))

An alternative:

=SUMIF(B:B,"HOTEL",A:A)/COUNTIF(B:B,"HOTEL")
 
B

Bernard Liengme

This array function works =AVERAGE(IF(B:B="hotel",A:A,""))
Redeemer to commit with CTRL+SHIFT+ENTER

This non-array (commit with ENTER) also works
=SUMIF(B:B,"hotel",A:A)/COUNTIF(B:B,"hotel")

And this non-array works only in XL2007
=AVERAGEIF(B1:B7,"hotel",A1:A7)

best wishes
 
G

Guest

Thanks - that gives me what I need!

JE McGimpsey said:
One way:

Array-entered (CTRL-SHIFT-ENTER or CMD-RETURN):

=AVERAGE(IF(B1:B100="HOTEL",A1:A100))

An alternative:

=SUMIF(B:B,"HOTEL",A:A)/COUNTIF(B:B,"HOTEL")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top