+ Reply to Thread
Results 1 to 7 of 7

How to Count with 2 conditions?

  1. #1
    Forum Contributor
    Join Date
    07-29-2005
    Location
    Singapore
    MS-Off Ver
    2007
    Posts
    253

    Question How to Count with 2 conditions?

    Hi,

    Now I got another problem...

    A1 = Apple
    A2 = Pear
    A3 = Orange
    A4 = Starfruit
    A5 = Apple
    A6= Apple

    B1 = 1
    B2 = 1
    B3 = 1
    B4 = 0
    B5 = 0
    B6= 1

    I want to count the apples but second condition is that B1:B6 must be greater than 0.

    I search example for COUNTIF but it only has COUNTIF(range,criteria)
    I tried =COUNTIF(A1:A5,AND("APPLE",B1:B5>0)) but it gives me the wrong count.

  2. #2
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: How to Count with 2 conditions?

    try
    =SUMPRODUCT((A1:A6="Apple")*(B1:B6>0))
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: How to Count with 2 conditions?

    Is this the same as your previous question?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Forum Contributor
    Join Date
    07-29-2005
    Location
    Singapore
    MS-Off Ver
    2007
    Posts
    253

    Re: How to Count with 2 conditions?

    Quote Originally Posted by royUK View Post
    Is this the same as your previous question?
    Hi Roy, nope, it's different. I mean the question was the same as the one you asked me to post as a new thread but the function is different.

    Hi contaminated, the count seems to be wrong. Let me try again later. I got to go away for a while.

  5. #5
    Forum Contributor
    Join Date
    07-29-2005
    Location
    Singapore
    MS-Off Ver
    2007
    Posts
    253

    Re: How to Count with 2 conditions?

    Quote Originally Posted by contaminated View Post
    try
    =SUMPRODUCT((A1:A6="Apple")*(B1:B6>0))

    Hi contaminated! It works!!!! Thanks.

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,033

    Re: How to Count with 2 conditions?

    Quote Originally Posted by contaminated View Post
    try
    =SUMPRODUCT((A1:A6="Apple")*(B1:B6>0))
    If B1:B6 can't be negative then =SUMPRODUCT(--(A1:A6="Apple");B1:B6) is enough
    Never use Merged Cells in Excel

  7. #7
    Forum Contributor
    Join Date
    07-29-2005
    Location
    Singapore
    MS-Off Ver
    2007
    Posts
    253

    Question Re: How to Count with 2 conditions?

    Quote Originally Posted by contaminated View Post
    try
    =SUMPRODUCT((A1:A6="Apple")*(B1:B6>0))
    Hi,

    Somehow there is a different column which gave 0 count. Not sure why.

    =SUMPRODUCT((Q11:Q83="Orange")*(Z11:Z83>0))

    Number of oranges are counted correctly but when I do SUMPRODUCT, it gave me 0. Did I do something wrong or change something without realizing it?

    If I want to count Q11:Q83="Orange" and Z11:Z83="1", can I still use SUMPRODUCT?

    Hi Guys, I just found out I need to put a " ' " in front of 1 for the SUMPRODUCT to count. Why is that so? Are there any other characters that will prevent counting?
    Last edited by Lewis Koh; 04-21-2010 at 12:20 PM. Reason: Tried alternative but can;t work.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1