+ Reply to Thread
Results 1 to 8 of 8

COUNTIFS with OR condition

  1. #1
    Forum Contributor
    Join Date
    04-19-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    180

    COUNTIFS with OR condition

    Hi

    I have 3 columns. I want to count the number of 1s (could actually be 1-/1/1+) in column A and the number of 1s in EITHER columns B and C

    so for e.g. if cell A1 contained 1 and celll B1 contained 2 and cell C1 contained 1 ... then the count would return 1

    and if cell A1 contained 1 and cell B1 contained 1 and cell C1 contained 2 ... then the count would still return 1

    I think I would need something like
    Please Login or Register  to view this content.
    ????? But would need an AND/OR condition for columns B and C.


    Hope that makes sense and someone can help.

    TIA
    Last edited by technik; 09-25-2019 at 07:30 AM.

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,065

    Re: COUNTIFS with OR condition

    You should regard all paramaters in COUNTIFS as AND nor OR

    use this instead
    =COUNTIFS(A1:A40,1,B1:B40,1)+COUNTIFS(A1:A40,1,C1:C40,1)

    NOTE: If A1 contains 1 and B1 contains 1 and C1 contains 1 this would count as 2 not 1 (1 for A and B, 1 for A and C)

    or use

    =SUMPRODUCT((A1:A40=1)*((B1:B40=1)+(C1:C40=1)))
    which will produce 1 in the above NOTE
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Contributor
    Join Date
    04-19-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: COUNTIFS with OR condition

    Thanks Special-K

    I only need a count of 1 is there was a 1 in all 3 columns.

    As the values can actually be 1-/1/1+ (see post 1) then assuming I am to use a wildcard?

  4. #4
    Valued Forum Contributor
    Join Date
    04-27-2015
    Location
    Abu Dhabi, U.A.E
    MS-Off Ver
    Office 365 | 2016
    Posts
    696

    Re: COUNTIFS with OR condition

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

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,421

    Re: COUNTIFS with OR condition

    The wildcard should be "1*".

    This would work:

    =COUNTIFS($A$1:$A$40,"1*",$B$1:$B$40,"1*",$C$1:$C$40,"1*")

    only if there were a 1 in every cell in all three ranges, but I don't think that's really what you want. Are you wanting to do this without a helper column?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  6. #6
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,065

    Re: COUNTIFS with OR condition

    Quote Originally Posted by technik View Post
    I only need a count of 1 is there was a 1 in all 3 columns.
    So where would the OR come into it?

    That's A is 1 AND B1 is 1 AND C is 1.

  7. #7
    Forum Contributor
    Join Date
    04-19-2010
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    180

    Re: COUNTIFS with OR condition

    Hi

    Just re-read my post and realised I mistyped. Apologies.

    I meant to say only need a count if 1* in column A and a 1* in EITHER columns B and C. So using your second piece of code in post 2 but was asking about the wildcard.

    Apologies again- long day.

  8. #8
    Registered User
    Join Date
    05-25-2012
    Location
    Chennai,TamilNadu,India
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    61

    Re: COUNTIFS with OR condition

    Hi,

    Hope this helps
    =SUMPRODUCT((LEFT(A2:A6,1)="1")*((LEFT(B2:B6,1)="1")+(LEFT(C2:C6,1)="1")))-COUNTIFS(A2:A6,1,B2:B6,1,C2:C6,1)

+ 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] Multiple Condition Countifs with Uniqueness as Condition
    By semantics in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 02-21-2017, 05:21 PM
  2. COUNTIFS using date as condition
    By aijp in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-21-2013, 04:27 PM
  3. [SOLVED] Countifs with a date as a condition
    By nickmessick1 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-06-2013, 07:58 AM
  4. [SOLVED] Using COUNTIFS between dates when one more condition - can they be in one formula or not?
    By RogerRangeRover in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-04-2012, 01:32 PM
  5. Replies: 3
    Last Post: 12-16-2011, 10:55 AM
  6. Replies: 4
    Last Post: 08-25-2010, 07:02 AM
  7. COUNTIFS with a variable condition
    By cjsec9 in forum Excel General
    Replies: 2
    Last Post: 04-01-2009, 02:51 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