+ Reply to Thread
Results 1 to 5 of 5

COUNTIF vs COUNTIFS vs SUMPRODUCT

Hybrid View

  1. #1
    Registered User
    Join Date
    05-27-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    12

    COUNTIF vs COUNTIFS vs SUMPRODUCT

    So, I'm trying to count of the number of occurrences of text that happen between two dates among multiple sheets in a workbook, and I cannot get the correct number. I have dates in the E column of each worksheet, and the text I want to count is in column F. For the dates I want to limit, I have them in cells E5 and E6 on the same sheet as the formulas. I currently have the E5/E6 cells dated 01-01-05 and 28-05-13 (there are no dates that go back to 2005, I'm doing this to test the formulas for accurate results before I start limiting).

    If I use a COUNTIF, it returns 15. (expected)
    =COUNTIF(Sheet2!$F:$F,text)
    If I try to use a COUNTIFS to limit the date, it returns 0 even if I don't put the end date.
    =COUNTIFS(Sheet2!$F:$F,text,Sheet2!$E:$E,">="&$E$5)
    If I try a SUMPRODUCT from the start date, it returns the expected number if I don't put the end date. Which will return 0 if I do.
    =SUMPRODUCT((Sheet2!$F$3:$F$100 = text)*(Sheet2!$E3:$E$100 >= $E$5))-SUMPRODUCT((Sheet2!$F$3:$F$100 = text)*(Sheet2!$E3:$E$100 > $E$6))
    Is there something I'm missing that would cause both the COUNTIFS and SUMPRODUCT functions to return incorrect values? Any help is appreciated, thanks!
    Last edited by FASTiger; 05-27-2013 at 11:21 PM.

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: COUNTIF vs COUNTIFS vs SUMPRODUCT

    Which column contains the dates?
    Your countifs is looking at E but sumproduct is looking at F.

    Are your dates really dates?
    Use =ISNUMBER(E3) to test
    If its true its a real date

  3. #3
    Registered User
    Join Date
    05-27-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: COUNTIF vs COUNTIFS vs SUMPRODUCT

    Good catch on the SUMPRODUCT, although they are correct in my spreadsheet. Column E has the dates.

    Oddly enough, some of the dates are not correctly being identified as numbers. Is there a way to force them to be read as numbers in the formulas?

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,047

    Re: COUNTIF vs COUNTIFS vs SUMPRODUCT

    The only way your dates would not be regognised as dates/numbers is if there are NOT dates/numbers, but text that looks like a date. test with =isnumber(cell_ref)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Registered User
    Join Date
    05-27-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: COUNTIF vs COUNTIFS vs SUMPRODUCT

    Yeah, it looks like a bunch of dates were being recognized as text instead of numbers. Is there a way to force a formula to read it as a date, though?

    I mean, I can go through and use something like DATEVALUE and manually change each date that needs it, but the spreadsheet is edited by several people. If someone ends up putting dates in as text, then these formulas won't work...

    Edit: Actually, it looks like I can just use Data Validation to force those columns to only accept numbers. That should fix things!
    Last edited by FASTiger; 05-28-2013 at 02:43 AM.

+ 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