+ Reply to Thread
Results 1 to 8 of 8

Sumproduct date forumla regards 1st of the month as occurring in 2 seperate months

  1. #1
    Registered User
    Join Date
    05-07-2009
    Location
    leeds, england
    MS-Off Ver
    Excel 2007
    Posts
    29

    Sumproduct date forumla regards 1st of the month as occurring in 2 seperate months

    Hello all,

    I have the following formula which gives me the sum of accidents in a specific month:

    Please Login or Register  to view this content.
    A1 is the department
    B2 is the incident code (e.g. "1p")
    A10 is the month (in this case august)

    The problem I have is that if an incident occurs on the 1st of the month my formula counts it as two seperate incidents, in two seperate months

    For example, on the dummy workbook provided:

    a 1p incident, in demolition department, on 1/8/09, is flagged in both july and august.

    How to I stop incidents that occur on the 1st of the month from being regarded as occurring in 2 months?

    Many Thanks

    Rich

    p.s. if Donkeyote reads this, I know you said that countif is better then sumproduct but I coundnt get it to work for me!
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Sumproduct date forumla regards 1st of the month as occurring in 2 seperate month

    You need one more argument. In B3 use this instead, copy down and across:

    =SUMPRODUCT(--(Incidents!$A$4:$A$302=$A$1),--(Incidents!$B$4:$B$302=B$2),--(Incidents!$C$4:$C$302>=$A3),--(Incidents!$C$4:$C$302>=DATE(YEAR($A3),MONTH($A3),1)),--(Incidents!$C$4:$C$302<DATE(YEAR($A3),MONTH($A3)+1,1)))
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

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

    Re: Sumproduct date forumla regards 1st of the month as occurring in 2 seperate month

    Your are doubling up because of:

    Please Login or Register  to view this content.
    should be < only ... ie date must be < 1st of following month (not < or = to)

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

    Re: Sumproduct date forumla regards 1st of the month as occurring in 2 seperate month

    Quote Originally Posted by his5r2m View Post
    p.s. if Donkeyote reads this, I know you said that countif is better then sumproduct but I coundnt get it to work for me!
    Yes, if backwards compatibility is not an issue you really should use COUNTIFS as it is significantly more efficient... the formula you would use would be:

    Please Login or Register  to view this content.
    Applied across Matrix.

    (note use of EDATE - in XL2007 this is available by default whereas in earlier versions it required activation of the Analysis ToolPak Add-In (via Tools))

  5. #5
    Registered User
    Join Date
    05-07-2009
    Location
    leeds, england
    MS-Off Ver
    Excel 2007
    Posts
    29

    Question Re: Sumproduct date forumla regards 1st of the month as occurring in 2 seperate month

    Thanks for that JB, it worked great.

    But I'm having trouble applying the new argument to other formulas in the sheet.

    I have a column, "No. of Days Lost", in demolition sheet, with the forumla:

    Please Login or Register  to view this content.
    (for July)

    This column is different to the other cells because is counts the values in column I, rather then counting the instances of various incident codes.

    I've tried inserting the new argument to ensure that incidents on the 1st of the month are only regarded to occur in one month rather then two, but keep getting an error message.

    Rich

  6. #6
    Registered User
    Join Date
    05-07-2009
    Location
    leeds, england
    MS-Off Ver
    Excel 2007
    Posts
    29

    Re: Sumproduct date forumla regards 1st of the month as occurring in 2 seperate month

    thanks DonkeyOte, youre a genius!

    Sorry for posting my question. I didnt know that my post was still being discussed after JB's inital reply.

    Thanks again

    Rich

+ 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