+ Reply to Thread
Results 1 to 12 of 12

Count number of rows meeting either criteria

  1. #1
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Count number of rows meeting either criteria

    Hi,

    I'm having brain freeze here (maybe because it's 3 AM), but I'm trying to count how many rows with two different criteria. It' really the opposite of countifs. So in Column A let's say there are countries and in column B there are currencies. I want to know how many rows contain "USA" in column A OR "USD" in column B. If I wanted both then it could be:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Thanks.

    abousetta
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  2. #2
    Valued Forum Contributor
    Join Date
    08-04-2011
    Location
    UK
    MS-Off Ver
    Excel 2021
    Posts
    346

    Re: Count number of rows meeting either criteria

    this for the either

    =Countif(A:A,"USA")+Countif(B:B,"USD")
    Last edited by AlanY; 11-14-2014 at 05:18 AM.

  3. #3
    Forum Contributor
    Join Date
    08-04-2014
    Location
    Riga
    MS-Off Ver
    2010
    Posts
    579

    Re: Count number of rows meeting either criteria

    So you want them seperate not together? Why not use COUNTIF then instead of COUNTIFS? I'm probably missing the point, and its not nearly 3 AM

  4. #4
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Count number of rows meeting either criteria

    sorry deleted
    Last edited by samba_ravi; 11-14-2014 at 05:22 AM.
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  5. #5
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Count number of rows meeting either criteria

    Maybe create a column C

    =if(or(A1="USA",B1="USD","*","")

    Then in D countif(C:C, "*")
    Happy with my advice? Click on the * reputation button below

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count number of rows meeting either criteria

    Quote Originally Posted by AlanY View Post
    this for the either

    =Countif(A:A,"USA")+Countif(B:B,"USD")
    That will double-count any rows for which the column A entry is "USA" and the column B entry is "USD", which I don't believe is what is required.

    Quote Originally Posted by nflsales View Post
    =sum(Countif(A:A,{"USA","USD"}))
    That's only looking at column A.

    Try:

    =SUMPRODUCT(0+((A1:A10="USA")+(B1:B10="USD")>0))

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  7. #7
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Count number of rows meeting either criteria

    I think AlanY will double count and NFLsales will only work if they're both in the one column

  8. #8
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Count number of rows meeting either criteria

    =sum(index((((a:a="usa")+(b:b="usd"))>0)*1,0))

  9. #9
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Count number of rows meeting either criteria

    You are right XOR LX,
    By oversight it was happened

  10. #10
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Count number of rows meeting either criteria

    Quote Originally Posted by nflsales View Post
    =sum(index((((a:a="usa")+(b:b="usd"))>0)*1,0))
    ?? You want to process a formula over two million cells?

    Remember that, unlike COUNTIF(S)/SUMIF(S), formulas such as the above are forced to calculate over all cells within the ranges passed to it, whether technically beyond the last-used cell or not.

    And why use a combination of SUM and INDEX when SUMPRODUCT is designed just for that purpose?

    Regards

  11. #11
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Count number of rows meeting either criteria

    Thanks everyone. Sumproduct by XOR LX and Sum/Index by nflsales both work. Reps for everyone

  12. #12
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Count number of rows meeting either criteria

    Sumproduct does seem the most appropriate choice in this situation, but always good to know that multiple options exist. Another option that came to my mind was:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    but thought that there must be a better way.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Count of pupils meeting 'less than' criteria...
    By sezza79 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-05-2014, 09:27 AM
  2. Count rows meeting multiple criteria of multiple values
    By borcimaeh in forum Excel General
    Replies: 4
    Last Post: 08-24-2014, 02:37 PM
  3. lookup and count if meeting criteria
    By reghu in forum Excel General
    Replies: 6
    Last Post: 09-09-2010, 07:41 AM
  4. Record count meeting 4 criteria
    By harleypop in forum Excel General
    Replies: 6
    Last Post: 03-17-2009, 08:33 PM
  5. [SOLVED] count records meeting three criteria
    By Laura in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-21-2005, 01:50 PM

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