+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 19

Thread: Help needed with COUNTIFS function

  1. #1
    Registered User
    Join Date
    10-03-2011
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    51

    Help needed with COUNTIFS function

    Hello...I'm stuck again!

    I have a spreadsheet with target dates for task completion in column AH and actual completion dates in column AL. I need to count how many times the actual date (in AL) was less than or equal to the target date(in AH) and present this as a percentage to demonstrate what percentage of the time we hit target. To make this even more complex, Column V lists which department the task belonged to and I ideally need to be able to just perform the above calculation for those entries where column V = "Factory Quality"

    Thank you very much for your help.

  2. #2
    Registered User
    Join Date
    10-03-2011
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    51

    Re: Help needed with COUNTIFS function

    If it makes it easier, it would be really useful to have a solution to the first part of the query, ignoring the conditions relating to column V....

  3. #3
    Valued Forum Contributor
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    1,944

    Re: Help needed with COUNTIFS function

    Assuming your data is in rows 2:100 try =COUNTIFS(V2:V100,"Factory Quality",AH2:AH100,"<=" & AL2:AL100)/COUNTIF(V2:V100,"Factory Quality")

  4. #4
    Forum Guru
    Join Date
    10-28-2008
    Location
    Not here anymore
    MS-Off Ver
    irrelevant
    Posts
    10,150

    Re: Help needed with COUNTIFS function

    Hello,

    what would make it easier is a sample sheet with the expected result.

    Try this formula (adjust ranges to suit)

    =SUMPRODUCT(--(AL2:AL11<=AH2:AH11),--(V2:V11="Factory Quality"))/COUNTIF(V2:V11,"Factory Quality")
    Last edited by teylyn; 10-25-2011 at 06:12 AM.

  5. #5
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,052

    Re: Help needed with COUNTIFS function

    This "array formula" will give you the percentage of dates in AL <= dates in AH for all rows that have dates in AL and have "Factory Quality" in column V - I assumed data from row 2 to row 1000, change as required

    =AVERAGE(IF(V2:V1000="Factory Quality",IF(ISNUMBER(AL2:AL1000),IF(AL2:AL1000<=AH2:AH1000,1,0))))

    confirmed with CTRL+SHIFT+ENTER
    Audere est facere

  6. #6
    Forum Guru
    Join Date
    10-28-2008
    Location
    Not here anymore
    MS-Off Ver
    irrelevant
    Posts
    10,150

    Re: Help needed with COUNTIFS function

    Andrew, this bit:

    =COUNTIFS(V2:V100,"Factory Quality",AH2:AH100,"<=" & AL2:AL100)

    always returns 0

  7. #7
    Registered User
    Join Date
    10-03-2011
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    51

    Re: Help needed with COUNTIFS function

    That is FANTASTIC! Thank you so much. It works!.....the reply from daddylonglegs, I mean

  8. #8
    Valued Forum Contributor
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    1,944

    Re: Help needed with COUNTIFS function

    No need for the SUMPRODUCT voodoo if the OP is using Excel 2007, Teylyn

    Edited to add: Sorry, work Internet connection borked as I posted this. I'm obviously behind the trend.

  9. #9
    Valued Forum Contributor
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    1,944

    Re: Help needed with COUNTIFS function

    Quote Originally Posted by teylyn View Post
    Andrew, this bit:

    =COUNTIFS(V2:V100,"Factory Quality",AH2:AH100,"<=" & AL2:AL100)

    always returns 0
    Not in my test workbook it doesn't.

  10. #10
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,052

    Re: Help needed with COUNTIFS function

    Quote Originally Posted by teylyn View Post
    Andrew, this bit:

    =COUNTIFS(V2:V100,"Factory Quality",AH2:AH100,"<=" & AL2:AL100)

    always returns 0
    It's actually going to return a 99 element array - element 1 being the result of =COUNTIFS(V2:V100,"Factory Quality",AH2:AH100,"<=" & AL2), element 2 being =COUNTIFS(V2:V100,"Factory Quality",AH2:AH100,"<=" & AL3).....etc......i.e. it's comparing every entry in AH against each entry in AL in turn....

    That can be useful in some circumstances but not here where you want to compare each entry in AH2:AH100 with the entry from the same row in AL2:AL100....which is why you need a straight AL2:AL100<=AH2:AH100 within a function other than COUNTIFS.......
    Audere est facere

  11. #11
    Forum Guru
    Join Date
    10-28-2008
    Location
    Not here anymore
    MS-Off Ver
    irrelevant
    Posts
    10,150

    Re: Help needed with COUNTIFS function

    Andrew,

    Not in my test workbook it doesn't.
    I'll show you mine and you show me yours....
    It returns 0 in the attached.

    I'd like to see a file where it returns something else.
    Attached Files Attached Files

  12. #12
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,052

    Re: Help needed with COUNTIFS function

    As I said in my last post - the formula actually returns an array. If you put it in a single cell then the value displayed can differ depending on where you put it, as you have it in Z3 it will show the second element of the array, in this case the result of this formula

    =COUNTIFS(V2:V100,"Factory Quality",AH2:AH100,"<=" & AL3)

    That could, of course, return any value between 0 and 99 depending on the data

    If you put the same formula in Z4 it will possibly display a different result.....
    Audere est facere

  13. #13
    Valued Forum Contributor
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    1,944

    Re: Help needed with COUNTIFS function

    Daddylonglegs is, of course, correct and I obviously haven't got my brain in gear this morning.

    Thanks DLL & Teylyn.

  14. #14
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,052

    Re: Help needed with COUNTIFS function

    In the attached I still have that formula in Z3 - it returns 9 because I changed the data. Same formula in Z4 shows 1 because it's picking up a different value from the array.

    In AC3 proof that the formula returns a 99 element array - this formula

    =COUNTA(COUNTIFS(V2:V100,"Factory Quality",AH2:AH100,"<=" & AL2:AL100))

    "array entered"

    returns 99
    Attached Files Attached Files
    Audere est facere

  15. #15
    Registered User
    Join Date
    10-03-2011
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    51

    Re: Help needed with COUNTIFS function

    Oh my goodness....I don;t understand much of what you're talking about! Please can you confirm what the correct formula is that I should be using? Thank you

+ 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.2.0