+ Reply to Thread
Results 1 to 9 of 9

Best way to combine Countif and OR functions.

  1. #1
    Registered User
    Join Date
    03-29-2014
    Location
    Kentucky
    MS-Off Ver
    Excel 2013
    Posts
    2

    Question Best way to combine Countif and OR functions.

    There are 3 columns of data B2:B91 C2:C91 D2:D91. The information is simply yes or no. The 4th column of data (E2:E91) is male or female. Individually the data has been counted: =Countifs(B2:B91,"YES",E2:E91,"Male")
    =Countifs(B2:B91,"YES",E2:E91,"Female")
    =Countifs(C2:C91,"YES",E2:E91,"Male")
    =Countifs(C2:C91,"YES",E2:E91,"Female")
    =Countifs(D2:D91,"YES",E2:E91,"Male")
    =Countifs(D2:D91,"YES",E2:E91,"Female")

    I am trying to combine those three into 1 function. If any of the cells display a yes, then that person needs to be counted. The problem with separately adding these together is that there are 3 categories for each person. If 2 of the columns display yes, the count will treat that as 2 separate individuals. I need the function to only count the person once if "Yes" is displayed in any of the 3 columns.

    How should I go about this?

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Best way to combine Countif and OR functions.

    Try this regular formula to count rows where Yes occurs in B:D AND E=Male
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    03-29-2014
    Location
    Kentucky
    MS-Off Ver
    Excel 2013
    Posts
    2

    Re: Best way to combine Countif and OR functions.

    the 20s have to be switched to 91 of course, but that worked perfectly! Thank you so much!

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Best way to combine Countif and OR functions.

    Glad you got something you can use!
    Be sure to mark this thread as SOLVED (from the Thread Tools menu)

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Best way to combine Countif and OR functions.

    Here's another one...

    Data Range
    B
    C
    D
    E
    F
    G
    H
    1
    ------
    ------
    ------
    ------
    ------
    ------
    ------
    2
    No
    No
    No
    Male
    Male
    4
    3
    Yes
    Yes
    No
    Female
    Female
    3
    4
    No
    No
    No
    Female
    5
    Yes
    No
    No
    Male
    6
    Yes
    Yes
    Yes
    Male
    7
    Yes
    No
    No
    Female
    8
    No
    Yes
    Yes
    Female
    9
    Yes
    No
    Yes
    Male
    10
    No
    Yes
    Yes
    Male


    This formula entered in H2 and copied down:

    =SUMPRODUCT(--(MMULT(--(B$2:D$10="Yes"),{1;1;1})>0),--(E$2:E$10=G2))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Best way to combine Countif and OR functions.

    I'm not a big fan of MMULT (too difficult to explain)...but, I was a bit surprised that this worked:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by Ron Coderre; 03-29-2014 at 09:01 PM.

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Best way to combine Countif and OR functions.

    Nice and compact!

    The SUMPRODUCT version is about twice as fast to calculate on 100 rows of data.

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Best way to combine Countif and OR functions.

    Quote Originally Posted by Ron Coderre View Post
    I'm not a big fan of MMULT (too difficult to explain)
    Too difficult to explain how it works or too difficult to explain why you're not a fan?

    If it's the former, here's my attempt to explain how it works from a post many years ago:

    http://www.tech-archive.net/Archive/.../msg00758.html

    As you can see in the URL the post was originally in the old MS NNTP newsgroups and was "mirrored" in this other forum.

  9. #9
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Best way to combine Countif and OR functions.

    We've strayed off topic on this one...Please see my PM to you about this.

+ 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] How do I combine these two functions?
    By worlds&v in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-04-2014, 09:01 PM
  2. How do I combine the COUNTIF and the OR functions into a single command
    By gwilymh in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-19-2012, 04:35 PM
  3. [SOLVED] Combine 5 Functions into One
    By jo15765 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2012, 10:43 AM
  4. Combine sum, offset, and countif functions
    By cbarr1987 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-24-2012, 11:32 AM
  5. How do I combine COUNTIF and AND functions in Excel
    By J Roney in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-15-2005, 06:45 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