+ Reply to Thread
Results 1 to 8 of 8

COUNTIF: Data between 2 dates

  1. #1
    Registered User
    Join Date
    08-19-2010
    Location
    Boone, United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Question COUNTIF: Data between 2 dates

    Attempting to count data that lies b/t 2 dates AND that also meets specific criteria in another column


    1) Column P counts days between 2 dates and returns a numerical value
    Please Login or Register  to view this content.
    2) This counts how many cells from column P note that the 1st date and 2nd date are between 3 and 7 days of each other

    Please Login or Register  to view this content.
    3) This counts how many cells in column L contain the words Clean or Short

    Please Login or Register  to view this content.
    }

    4) What I want is to be able to count how many dates that fall between 4 and 7 days of each other also have the words Clean or Short in the L column.

    I figured out the formula that works when dates are less than or equal to 3 days apart

    Please Login or Register  to view this content.
    But when I substitute

    Please Login or Register  to view this content.

    with

    Please Login or Register  to view this content.
    it doesnt work.

    my best attempts:

    1)
    Please Login or Register  to view this content.
    (Returns 942... way off)

    2)
    Please Login or Register  to view this content.
    (Returns 1... way off)

    Ideally I would like to understand how to properly work COUNTIF formulas (i suppose its a syntax or order problem) so I dont have to spend 2 hours trying to figure it all out every time i hit a speed bump.

    I am using Excel 97

    EDITS: Trying to edit to Forum suggestions and rules. also included an example of what I am trying to do.
    Attached Files Attached Files
    Last edited by kitprattfall; 08-27-2010 at 05:03 PM. Reason: uploaded example 8/23

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: COUNTIF: Data between 2 dates

    A Pivot Table would probably be a good choice for this.
    However for a formula solution that uses multiple criteria, see this video tutorial on the use of SUMPRODUCT

    Also, see these pages: Summarize Data with SumProduct
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Registered User
    Join Date
    08-19-2010
    Location
    Boone, United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: COUNTIF: Data between 2 dates

    Thanks Palmetto, I've been looking over the sumproduct info. Seems to be in the right direction as far as getting me more towards using the most succinct and efficient formulas.

    Just need to figure out how to match across 3 criteria.

    return how many times a row has A or B in one column, G in another column, and Z or Y in a third. Lots of info.

    Pivot tables I am still learning. Thing about them is i am not sure how to make them presentable. The way i have my data reporting now is in a specific layout.

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: COUNTIF: Data between 2 dates

    It would be easier if you uploaded a sample workbook (I don't think you need the intermediate columns) but based on the information you gave, try this

    =SUMPRODUCT(--($P$2:$P$999<=14),-- ($P$2:$P$999 >=7), ($L$2:$L$999="clean")+ ($L$2:$L$999="short"))

    Does that work?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  5. #5
    Registered User
    Join Date
    08-19-2010
    Location
    Boone, United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: COUNTIF: Data between 2 dates

    Thanks for the tip, Chemist

    However, that formula did not work out for me, returns #VALUE! error. I am not sure why, perhaps something in the syntax. I am less familiar with the "--" and sumproduct in general.

    I also took your advise and uploaded a sample

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: COUNTIF: Data between 2 dates

    I modifed my SUMPRODUCT to reference two cells (min and max days for each set). I modified your column H into two columns for min and max days for each set See attachment.

    So in M4 for example, the formula is
    =SUMPRODUCT(--($F$2:$F$999<=I4),-- ($F$2:$F$999 >=H4), ($D$2:$D$999="clean")+ ($D$2:$D$999="short"))
    dragged down.

    Does that work for you?
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    08-19-2010
    Location
    Boone, United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: COUNTIF: Data between 2 dates

    Chemist, this does indeed work. A little different than I expected, but also something that didnt even cross my mind. Good thinking. Thinking out side of the cell. Perhaps one more question: Why sumproduct rather than countif. I imagine it is faster/more efficient for some reason?

    Otherwise: solved

    Edit: Premature SOLVED. I have no idea what is going on, but when I plug that formula into my spreadsheet, changing the cell references, I get the #VALUE! error.

    Thoughts?
    Last edited by kitprattfall; 08-24-2010 at 12:41 PM. Reason: Problem

  8. #8
    Registered User
    Join Date
    08-19-2010
    Location
    Boone, United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: COUNTIF: Data between 2 dates

    Something happened. I have no idea what is going on, but when I plug that formula into my spreadsheet, changing the cell references, I get the #VALUE! error.

    All i did was change

    =SUMPRODUCT(--($F$2:$F$999<=I4),-- ($F$2:$F$999 >=H4), ($D$2:$D$999="clean")+ ($D$2:$D$999="short"))

    to

    =SUMPRODUCT(--($P$58:$P$999<=BK24),-- ($P$58:$P$999 >=BJ24), ($L$58:$L$999="clean")+ ($L$58:$L$999="short"))

    No idea what is going on here. Thoughts?

    * Does it matter if some cells are blank in the Refrence column P58:P999 or L58:L999?


    ***Never mind, found out that there were some cells in the reference column (P) that were not numbers. I deleted those cells' values and it now works. Thank you.
    Last edited by kitprattfall; 08-27-2010 at 05:04 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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