Thread: percentage
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default percentage

=countif(b:b,"building a")

=sumproduct(--(b2:b100="building a"),--(a2:a100<500))
will count the number of entries that are less than 500, but have building a in
column B.

=countif(b2:b100,"building a")
will count the number of entries that have building a in column B.

So dividing:
=sumproduct(--(b2:b100="building a"),--(a2:a100<500))
/countif(b2:b100,"building a")

Adjust the ranges to match--but you can't use whole columns (except in xl2007).

=sumproduct() likes to work with numbers. The -- stuff changes trues and falses
to 1's and 0's.

Bob Phillips explains =sumproduct() in much more detail he
http://www.xldynamic.com/source/xld.SUMPRODUCT.html

And J.E. McGimpsey has some notes at:
http://mcgimpsey.com/excel/formulae/doubleneg.html

=========
xl2007 has a new function named =countifs(). You could use that instead of the
=sumproduct() portion.

Rene wrote:

Hi, I trying to write a formula that will look in column b for 'building A'
and calculate the number of times the cost is <500, as a percentage. 2
entries but only 1 is <500. Should return 50%

a2:b100
cost location
500 building a
100 building b
250 building c
100 building a


--

Dave Peterson