LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default COUNTIF to count rows with two conditions

You've all been a great help! I think this has completely resolved my
problem now.

Thanks!



"Roger Govier" wrote:

Hi

=SUMPRODUCT((G2:G350="C")*(B2:B350="Y")*(C2:C350))
Strictly speaking, as they are just numbers in column C, they don't need
to be enclosed within another set of parentheses, but I usually find it
easier to always enclose each term in this way.


--
Regards

Roger Govier


"Kaishain" wrote in message
...
Thanks again for the quick reply. It makes a lot more sense now.

However, I now have another problem:

There is a third column which contains different numbers (currency, in
this
case). The formula used to count the rows returned 31 rows that met
the
specified conditions. I now want to add the values of the third
column of
each of those rows. I want something like '=SUM(C1:C350)', but only
counting
the 31 rows found by the first formula.

Is it possible to do that?




"Roger Govier" wrote:

Hi

By and large there is no difference between the two methods.
In a few cases, one will work better than the other.

Sumproduct generally has its different terms separated by commas
=Sumproduct(term1,term2,term3).
In your case the terms are comparisons that will either result in a
True
or False result.
These results need to be coerced from True to 1 and False to 0 in
order
for Sumproduct to be able to produce a result.
The double unary minus -- is used to carry out the coercion.
The same could be achieved by adding 0 to the result or multiplying
by 1
=SUMPRODUCT((G2:G350="C")*1,(B2:B350="Y")*1)

In the other case, the coercion is automatically taking place by
using
the multiplication of the 2 terms within the Sumproduct, rather than
using a comma separator.

For a full discussion on this, Bob Phillips has an excellent treatise
at
http://xldynamic.com/source/xld.SUMPRODUCT.html

--
Regards

Roger Govier


"Kaishain" wrote in message
...

Thanks for replying!

They both seem to work for me. What's the difference? Is either
one
better
for one reason or another?

Thanks again



"Byron720" wrote:

This one works:

=SUMPRODUCT(--(G2:G350="C"),--(B2:B350="Y"))

"Kaishain" wrote:

I have a spreadsheet with 350 rows and two columns.

I want to count the number of rows which have BOTH the letter C
in
the first
column AND the letter Y in the second column.

I was thinking of using COUNTIF in a way similar to the
following:

'=COUNTIF(G2:G350,"C")+COUNTIF(B2:B350,"Y")'

However, this counts the number of CELLS which contain EITHER of
those two
letters. I want to count the number of ROWS with BOTH of those
letters. I'm
guessing COUNTIF is the wrong command to use, but that I want
something
similar to it.

Any suggestions would be much appreciated.

Thanks






 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
COUNTIF with multiple conditions Eric Excel Discussion (Misc queries) 3 October 16th 06 06:29 PM
Find and Count Frequency of Numeric Value in Non-Contiguous Rows Sam via OfficeKB.com Excel Worksheet Functions 2 September 17th 06 09:17 PM
Using CountIf with 2 conditions - help! Sarah Excel Worksheet Functions 6 May 23rd 06 07:18 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
Count on multiple values with duplicate rows Carla Excel Worksheet Functions 1 November 22nd 05 09:25 PM


All times are GMT +1. The time now is 10:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"