+ Reply to Thread
Results 1 to 5 of 5

COUNTIF to match criteria values from 2 columns

  1. #1
    Forum Contributor
    Join Date
    03-30-2007
    Location
    London, UK
    MS-Off Ver
    Microsoft Office 2007
    Posts
    317

    Smile COUNTIF to match criteria values from 2 columns

    Hi

    Can anyone tell me how I can use the COUNTIF (or any other function) that can be used to check for 2 criteria in multiple columns?

    For example in column X I need to search for Successful and in column G also check for M so that I can get the gender split.

    I have tried putting an AND logical function in there but it just returns the value of TRUE rather that a number which is what I needed.

    Thanks in advance for any help offered.
    Best Regards.

    Michael
    -----------------------------------
    Windows Vista, Microsoft Office 2007

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: COUNTIF to match criteria values from 2 columns

    Pre XL2007 you are looking at using SUMPRODUCT

    =SUMPRODUCT(--($G$1:$G$1000="M"),--($X$1:$X$1000="Successful"))

    note with SUMPRODUCT it is imperative to keep range sizes to a minimum given it is a "hungry" function in terms of performance.

    Have you thought of perhaps using a pivot table ?

  3. #3
    Forum Contributor
    Join Date
    03-30-2007
    Location
    London, UK
    MS-Off Ver
    Microsoft Office 2007
    Posts
    317

    Smile Re: COUNTIF to match criteria values from 2 columns

    Hi DonkeyOte,

    Thank you so much for your prompt reply. I did use a pivot table in the end, I just wanted to know if this could be done by a formula also and I thank you for providing me the function to do this. I have never used SUMPRODUCT before.

    Also my source data was exstracted from a db and there are several columns that contain blank cells and I was worried because I have read that there should be no blank rows or columns when using a Pivot Table report.

    What are the implications of blank cells?

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: COUNTIF to match criteria values from 2 columns

    A PT can't be set-up if the range contains blank headers.

    Nulls are generally more troublesome than Blanks, a Null is a text string so this can cause issues if interspersed amongst other numerical values in fields which you would otherwise like to "Group" etc in the PT.
    (and in reality the issue of Nulls/Blanks applies to more than just PTs...)
    Last edited by DonkeyOte; 09-22-2009 at 04:49 AM. Reason: typo

  5. #5
    Forum Contributor
    Join Date
    03-30-2007
    Location
    London, UK
    MS-Off Ver
    Microsoft Office 2007
    Posts
    317

    Smile Re: COUNTIF to match criteria values from 2 columns

    Quote Originally Posted by DonkeyOte View Post
    A PT can't be set-up if the range contains blank headers.

    Nulls are generally more troublesome than Blanks, a Null is a text string so this can cause issues if interspersed amongst other numerical values in fields which you would otherwise like to "Group" etc in the PT.
    (and in reality the issue of Nulls/Blanks applies to more than just PTs...)
    Thanks for this addional information and for your help, I really appreciate it the SUMPRODUCT function worked extremely well and returned the same value as the Pivot Table so I was able to confirm that my figures were correct.

+ 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