+ Reply to Thread
Results 1 to 14 of 14

Combine COUNTIF with OR

Hybrid View

  1. #1
    Registered User
    Join Date
    02-01-2014
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    61

    Combine COUNTIF with OR

    I want to do a count of all cells in column A that are less than 10 with all cells in column B that are more than 10 OR blank

  2. #2
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Combine COUNTIF with OR

    For this instead of COUNTIF use COUNTIFS function
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  3. #3
    Registered User
    Join Date
    02-01-2014
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Combine COUNTIF with OR

    I did. The issue is in column B I need a formula that will take all counts that are greater than 10 OR blank.

    To my knowledge the countifs formula cannot accept "OR()"

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

    Re: Combine COUNTIF with OR

    It can.

    See here for an explanation as to the necessary syntax:

    http://excelxor.com/2014/09/28/count...iteria_ranges/

    Regards
    Click * below if this answer helped

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

  5. #5
    Registered User
    Join Date
    02-01-2014
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Combine COUNTIF with OR

    This is not working:

    =SUM(COUNTIFS(A1:A4,"<"&10,B1:B4,{">"&10,0}))

  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: Combine COUNTIF with OR

    Quote Originally Posted by blens1 View Post
    This is not working:

    =SUM(COUNTIFS(A1:A4,"<"&10,B1:B4,{">"&10,0}))
    I thought you wanted blanks for the second criterion for column B, not zeroes?

    Regards

  7. #7
    Registered User
    Join Date
    02-01-2014
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Combine COUNTIF with OR

    You are correct in that case I would use "" but it is still not working

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,702

    Re: Combine COUNTIF with OR

    This works for me

    =SUM(COUNTIFS(A1:A4,"<10",B1:B4,{">10",""}))
    Audere est facere

  9. #9
    Registered User
    Join Date
    02-01-2014
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Combine COUNTIF with OR

    This is getting me so much closer and I definitely appreciate the help as it now works. But instead of 10 it now needs to refer to a cell.

    That will allow me to change it to 10 or 11 or whatever number is necessary at the time.

  10. #10
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,702

    Re: Combine COUNTIF with OR

    OK if you have 10 in C1 try this formula

    =SUMPRODUCT(COUNTIFS(A1:A4,"<"&C1,B1:B4,IF({1,0},">"&C1,"")))

  11. #11
    Registered User
    Join Date
    02-01-2014
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Combine COUNTIF with OR

    Well... all of this is actually referring to date's not numbers. Therefore it is not working as I think {1,0} would only work if it was a number

  12. #12
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,702

    Re: Combine COUNTIF with OR

    No, C1 can be a date, the {1,0} part is just a way to put both criteria in to an array

    Can you post the exact formula you tried?

    Notice that I changed SUM to SUMPRODUCT. You can keep SUM if you want but the formula will then need to be "array entered"

    If you still have problems making that work you could try simply adding two COUNTIFS functions like this

    =COUNTIFS(A1:A4,"<"&C1,B1:B4,">"&C1)+COUNTIFS(A1:A4,"<"&C1,B1:B4,"")

  13. #13
    Registered User
    Join Date
    02-01-2014
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    61

    Re: Combine COUNTIF with OR

    =SUMPRODUCT($A$1:$A$15,"<"&E2,$B$1:$B$15,IF({1,0},">"&E2,""))

    I have also attached the file but to ensure this works for the long time it is important that column B is greater than cell E2 OR blank.


    excel forum example.xlsx

  14. #14
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,702

    Re: Combine COUNTIF with OR

    You still need the COUNTIFS function in there, so the formula should be

    =SUMPRODUCT(COUNTIFS($A$1:$A$15,"<"&E2,$B$1:$B$15,IF({1,0},">"&E2,"")))

    For your example the correct answer is zero but if you appropriately that will work - note that if you have times with the dates that any time/date on a specific date will be deemed to be > than that date

+ 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] combine countif and mod functions
    By thebutlerdidit in forum Excel General
    Replies: 10
    Last Post: 02-09-2015, 03:55 PM
  2. Combine sum + offset + countif
    By parreich in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-06-2014, 05:37 AM
  3. [SOLVED] Best way to combine Countif and OR functions.
    By Matthew_Ky in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-30-2014, 10:57 AM
  4. Combine two COUNTIF criteria using SUM not going well
    By Padedo in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-26-2012, 07:51 AM
  5. [SOLVED] How do I combine 2 COUNTIF formulas??
    By MANDY in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-19-2006, 02:10 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