+ Reply to Thread
Results 1 to 6 of 6

counting with two conditions!

  1. #1
    Registered User
    Join Date
    06-24-2008
    Posts
    10

    counting with two conditions!

    Hi All,
    I want to count with two conditions in two different columns.

    WAIT AGE_YR
    0 82
    0 70
    0 82
    0 73
    0 68
    I used the following to count number of "wait" between 0 and 5 that has "AGE" between 70 and 85, but I get 1 which is wrong I should get 4.

    =SUMPRODUCT(IF((COUNTIF(A2:A6, "<=5") - COUNTIF(A2:A6, "<0" )),1,0), IF((COUNTIF(B2:B6, "<=85") - COUNTIF(B2:B6, "<70" )),1,0))

    can anyone help me?
    Thanks

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Try:

    =sumproduct((a2:a6<=5)*(a2:a6>=0)*(b2:b6<=85)*(b2:b6>=70))
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    06-24-2008
    Posts
    10
    Thanks a lot

    It worked!
    it was very efficient

  4. #4
    Registered User
    Join Date
    06-24-2008
    Posts
    10
    Is there anyway I can do the same thing without indicating the range of the columns? because in the dataset that i am working on, the columns have different size...

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    If you are in Excel 2007, you can you whole columns

    =sumproduct((a:a<=5)*(a:a>=0)*(b:b<=85)*(b:b>=70))

    If you are in earlier versions, you can indicate almost the whole column

    =sumproduct((a2:a65536<=5)*(a2:a65536>=0)*(b2:b65536<=85)*(b2:b65536>=70))

  6. #6
    Registered User
    Join Date
    06-24-2008
    Posts
    10
    Thanks again....

+ 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