Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

count base on 2 criteria 1

Status
Not open for further replies.

tikual

Technical User
Jun 10, 2003
237
HK
Hi all,

I have a table like this:

Server Brand Type

ABC Sun Server
BCD Sun Tape Drive
EFG Dell Server
JKL Sun Server

Result 2

If the row matches to "Sun" and "Server", then I would like to count it and the result should be 2. I try function "match" or "if" but not success. Any hints can be provided to me?

Thanks a lot!

tikual
 
In Access, it would look something like this:

SELECT Count(tablename.Brand) AS CountSS
FROM tablename
WHERE (((tablename.Brand)="Sun") AND ((tablename.Type)="Server"));


Let them hate - so long as they fear... Lucius Accius
 
I am sorry about my situation is under Excel. Thanks.

tikual
 
=SUMPRODUCT(--(B1:B10="Sun"),--(C1:C10="Server"))

Regards
Ken..........

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]
----------------------------------------------------------------------------
 
Thanks a lot!! But, could you please let me know what is the meaning of the sign -- before the array? I don't know why it works.

tikual
 
Hi,

B1:B10="Sun" returns an array of boolean values. As you want to do calculations with it, the double negative (--) coerces the boolean value to a numerical value. Excel does this automatically, but the formula calculates faster when you help it a bit.

(there are many other ways to coerce to a numerical value, but the double negative seems to have been adopted as the convention nowadays)

Cheers,

Roel
 
Thanks Rofeu, where can I find this information? I still not fully understand its usage.

tikual
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top