+ Reply to Thread
Results 1 to 7 of 7

Using Countifs, on entries in multiple columns

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-22-2009
    Location
    Henderson, KY
    MS-Off Ver
    Excel 2007
    Posts
    152

    Using Countifs, on entries in multiple columns

    In the attached workbook, I am trying to count the instances where there is an "x" is in one of the 2 cells next to an entry. between the dates given(month).
    I have this formula:

    =COUNTIFS('2010 PM'!$E$3:$E$193,"x",'2010 PM'!$D$3:$D$193,">="&'Spot PM count'!B4,'2010 PM'!$D$3:$D$193,"<="&'Spot PM count'!C4,'2010 PM'!$C$3:$C$193,"")+COUNTIFS('2010 PM'!$F$3:$F$193,"x",'2010 PM'!$D$3:$D$193,">="&'Spot PM count'!B4,'2010 PM'!$D$3:$D$193,"<="&'Spot PM count'!C4,'2010 PM'!$C$3:$C$193,"")

    and it works, for 1 of the 15 columns I need to search. Is there another way to do this? Or am I going to have 15 subtotals per month, to get the info I need?

    I am looking to automate the B5:M6 cells in the "Spot PM count" sheet. The handcounted numbers for this are in B19:M20 of the same sheet

    Thanks for any insight you can give me on this problem
    Attached Files Attached Files
    Last edited by Befuddled; 12-15-2010 at 07:36 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Using Countifs, on entries in multiple columns

    Can you explain how you get 5 for May, 7 for June and 10 for July?

    What exactly is getting counted?
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Contributor
    Join Date
    09-22-2009
    Location
    Henderson, KY
    MS-Off Ver
    Excel 2007
    Posts
    152

    Re: Using Countifs, on entries in multiple columns

    For example, in '2010 PM'!Y5:AA5 there is an entry of 11/29/10 and an x.
    For every date entry in '2010 PM'!D3:AV193, with a value between 11/1/10 and 11/30/10, I want to know how many "x"s there are in the 2 corresponding cells next to each of those entries. This would be the total for November.

    If you look in sheet "2010 PM" column C, each row either has an x, or not. I need to break down the total from above, into the total with an "x" in column C, and the total without an "x" in column C.

    So, in sheet "Spot PM Count" L19 I come up with an answer of 2 "x" entries in '2010 PM'!D3:AV193 that DO NOT have an "x" in column C
    and in sheet "Spot PM Count" L20 I come up with an answer of 8 "x" entries in '2010 PM'!D3:AV193 that DO have an "x" in column C
    Last edited by Befuddled; 12-14-2010 at 11:29 PM. Reason: try to clarify wording

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Using Countifs, on entries in multiple columns

    I come up with slightly differing numbers in some places...

    Try in B5:

    =SUMPRODUCT(('2010 PM'!$C$3:$C$193="x")*(TEXT('2010 PM'!$D$3:$AT$193,"mmmyy")=TEXT(B$4,"mmmyy"))*(('2010 PM'!$E$3:$AU$193="x")+('2010 PM'!$F$3:$AV$193="x")))
    copied across

    and in C5:

    =SUMPRODUCT(('2010 PM'!$C$3:$C$193<>"x")*(TEXT('2010 PM'!$D$3:$AT$193,"mmmyy")=TEXT(B$4,"mmmyy"))*(('2010 PM'!$E$3:$AU$193="x")+('2010 PM'!$F$3:$AV$193="x")))
    copied across

  5. #5
    Forum Contributor
    Join Date
    09-22-2009
    Location
    Henderson, KY
    MS-Off Ver
    Excel 2007
    Posts
    152

    Re: Using Countifs, on entries in multiple columns

    Thanks very much, this works great. I knew there had to be a more elegant, and less cumbersome, way to do this.

    Any numbers that were different, must have been a miss-count from when I did it by hand

  6. #6
    Forum Contributor
    Join Date
    09-22-2009
    Location
    Henderson, KY
    MS-Off Ver
    Excel 2007
    Posts
    152

    Re: Using Countifs, on entries in multiple columns

    Just a question about that formula.
    =SUMPRODUCT(('2010 PM'!$C$3:$C$193<>"x")*(TEXT('2010 PM'!$D$3:$AT$193,"mmmyy")=TEXT(B$4,"mmmyy"))*(('2010 PM'!$E$3:$AU$193="x")+('2010 PM'!$F$3:$AV$193="x")))

    by using D3:AT193 for the text cells and using E3:AU193 for the 1st "x" and F3:AV193 for the 2nd "x", the formuls know to ONLY look in the 2 cells next to the entry that fits the text criteria, and the <>"x" criteria in column C?

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Using Countifs, on entries in multiple columns

    Have a read through this article: Sumproduct

    Sumproduct is a versatile function.

    It is a matter of just lining up the arrays so the results line up.

    IF you notice the E3:AU and F3:AV3 are offset arrays from the D3:AT3... so what I am doing is lining up the left arrays so that the results are in the same relative position.

+ 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