+ Reply to Thread
Results 1 to 11 of 11

Count Multiple columns and criteria

  1. #1
    Registered User
    Join Date
    11-07-2013
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    14

    Count Multiple columns and criteria

    Hi,

    I know that this has been answered in some form or another, yet I still am having troubles.

    What I'm trying to do count the TRUE values in multiple columns, if the criteria is correct in another column.

    I've tried countifs but end up having the company included into the count, or only count the row that matches all the criteria. If I do =COUNTIFS(A2:A7,"A",B2:B7,"TRUE")+COUNTIF(C2:C7,"TRUE") then I get 5. When I change it to +COUNTIFS(A2:A7,"A",C2:C7,"TRUE") it works but there's a time where I need to check up to 8 Options.

    I'd rather a easier way to do this if there is one please let me know.


    Any help is welcomed.

    Company Option 1 Option 2
    a True True
    b True False
    c True False
    a True False
    a True False
    b True True

  2. #2
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: Count Multiple columns and criteria

    What answer do you expect here?
    If you are http://www.excelforum.com/image.php?type=sigpic&userid=125481&dateline=1392355029happy with the results, please add to the contributor's
    reputation by clicking the reputation icon (star icon).




    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.
    To undo, select Thread Tools-> Mark thread as Unsolved.
    http://www.excelaris.co.uk

  3. #3
    Registered User
    Join Date
    11-07-2013
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    14

    Re: Count Multiple columns and criteria

    I should get 4 as there's 4 times True shows up for company "a". If I put all my criteria into one countifs statement then it will count the number of times company "a" appears and gives me 7.

  4. #4
    Valued Forum Contributor AZ-XL's Avatar
    Join Date
    03-22-2013
    Location
    Azerbaijan, Baku
    MS-Off Ver
    Excel 2007
    Posts
    603

    Re: Count Multiple columns and criteria

    Hi
    1st alternative
    =COUNTIFS(A2:A7,"a",B2:B7,TRUE)+COUNTIFS(A2:A7,"a",C2:C7,TRUE)

    2nd
    =SUMPRODUCT((A2:A7="a")*B2:B7+(A2:A7="a")*C2:C7)
    Appreciate the help? CLICK *

  5. #5
    Registered User
    Join Date
    11-07-2013
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    14

    Re: Count Multiple columns and criteria

    Thanks that worked, I was having trouble with the sumproduct formula, couldn't quite understand how it work.

  6. #6
    Valued Forum Contributor AZ-XL's Avatar
    Join Date
    03-22-2013
    Location
    Azerbaijan, Baku
    MS-Off Ver
    Excel 2007
    Posts
    603

    Re: Count Multiple columns and criteria

    Maybe this
    Column A Names. Row1 Headers. Range B2:I7 with value(true/false)

    =SUMPRODUCT(($A$2:$A$7="A")*$B$2:$I$7)

  7. #7
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: Count Multiple columns and criteria

    Why don't you add a column, = AND(A1 = "a",OR(Opt1,Opt2)) Then count TRUE values with COUNTIF.

    John

  8. #8
    Registered User
    Join Date
    11-07-2013
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    14

    Re: Count Multiple columns and criteria

    Quote Originally Posted by AZ-XL View Post
    Maybe this
    Column A Names. Row1 Headers. Range B2:I7 with value(true/false)

    =SUMPRODUCT(($A$2:$A$7="A")*$B$2:$I$7)

    This works perfectly. Thanks for the help.

  9. #9
    Valued Forum Contributor AZ-XL's Avatar
    Join Date
    03-22-2013
    Location
    Azerbaijan, Baku
    MS-Off Ver
    Excel 2007
    Posts
    603

    Re: Count Multiple columns and criteria

    You are welcome. Thanx for feedback

  10. #10
    Registered User
    Join Date
    11-07-2013
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    14

    Re: Count Multiple columns and criteria

    Two more questions for sumproduct, if I want to add another criteria to the array how would I do that. To use the example from the op if I wanted to include company c in the count then would it be:
    =SUMPRODUCT(($A$2:$A$7={"A","C"})*$B$2:$I$7)
    OR
    =SUMPRODUCT(($A$2:$A$7="A")*$B$2:$I$7)+SUMPRODUCT(($A$2:$A$7="C")*$B$2:$I$7)

    Or is there a better way to solve for this?

  11. #11
    Valued Forum Contributor AZ-XL's Avatar
    Join Date
    03-22-2013
    Location
    Azerbaijan, Baku
    MS-Off Ver
    Excel 2007
    Posts
    603

    Re: Count Multiple columns and criteria

    Hi
    Second formula of yours seems logical. First one may give wrong result. Also you may try this
    =SUMPRODUCT(IF(ISERROR(SEARCH($A$2:$A$7,"ac")),0,1)*$B$2:$I$7)

+ 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. Count of Multiple Criteria Across Columns
    By BERthe Bunny in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-24-2013, 04:43 AM
  2. Count or Sum multiple columns when the criteria is met
    By sarinky in forum Excel General
    Replies: 5
    Last Post: 02-09-2012, 12:55 AM
  3. Count instances of a string across multiple columns with multiple criteria
    By rpthoth in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-01-2012, 09:23 AM
  4. Replies: 1
    Last Post: 09-03-2010, 12:52 PM
  5. [SOLVED] How can I count items in multiple columns with different criteria.
    By ChileRed in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-21-2006, 03:20 PM

Tags for this Thread

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