+ Reply to Thread
Results 1 to 7 of 7

SUMPRODUCT issue with summing based off date conditions

  1. #1
    Registered User
    Join Date
    06-06-2012
    Location
    California, USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    SUMPRODUCT issue with summing based off date conditions

    Hello everyone,

    I am having an issue using the SUMPRODUCT function in the attached scenario (Cell F2) to SUM a set of numbers in range (D5:D32) based off a date range criteria. The criteria range dates are in cells A5:A32, and the conditions are referencing two dates (A2 & B2).

    I've tried the formula =SUMPRODUCT((D5:D32)*(A5:A32>=A2)*(A5:A32<=B2)) however I am getting the #VALUE! error, and I'm not sure why. I've used the SUMPRODUCT function successfully as a SUMIFS function in previous scenarios, however I can't make it seem to work on this one.

    I am already using the SUMPRODUCT function successfully in cell G2 to get the count based off the necessary conditions; but I need the sum to calculate an average.

    Any help guys on whay I am doing wrong? Or what I should do to get the sum of D5:D32 based off the dates in A5:A32 using the 2 dates in A2 & B2 as criteria?

    Workbook attached.

    I appreciate it
    Attached Files Attached Files

  2. #2
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: SUMPRODUCT issue with summing based off date conditions

    Hi GuitarGod,

    Welcome to the forum.


    Use the below formula:-


    {=SUM(IF(($B$5:$B32>=$A$2)*($B$5:$B32<=$B$2),($D$5:$D32),""))}
    SUMPRODUCT issue.xlsx

    Above is an array formula and need to be entered using ctrl + Shift + Enter key combination..thanks.

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  3. #3
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: SUMPRODUCT issue with summing based off date conditions

    As your ranges also contain time, when you try to get results after or equal 4/4 and before or equal to 5/4 you will only get the data for 4/4. Is that what you want?

  4. #4
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: SUMPRODUCT issue with summing based off date conditions

    If you are looking DATE part only in column A, use SUMIF instead of SUMPRODUCT

    F2:

    =SUMIF(A5:A32,">="&A2,D5:D32)-SUMIF(A5:A32,">="&B2+1,D5:D32)

    G2:

    =SUMPRODUCT((A5:A32>=A2)*(A5:A32<B2+1)*(D5:D32<>""))

    You could also use SUMIFS & COUNTIFS respectively.
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  5. #5
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: SUMPRODUCT issue with summing based off date conditions

    The cause of the #VALUE is because your original formula tries to use "null
    values" (presumably null strings, not empty cells) in the arithmetic
    expression.

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: SUMPRODUCT issue with summing based off date conditions

    Quote Originally Posted by Pepe Le Mokko View Post
    The cause of the #VALUE is because your original formula tries to use "null
    values" (presumably null strings, not empty cells) in the arithmetic
    expression.
    ....and you can fix that by not multiplying by the sum range, i.e. use

    =SUMPRODUCT(D5:D32,(A5:A32>=A2)*(A5:A32<=B2))

    ....although that formula returns zero for your example because there are no rows which meet both criteria....but it'll work if you have some different dates....
    Audere est facere

  7. #7
    Registered User
    Join Date
    06-06-2012
    Location
    California, USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: SUMPRODUCT issue with summing based off date conditions

    Thanks guys for your expertise! All of your solutions worked. I appreciate those who helped me within the same function (SUMPRODUCT) I am trying to get acclimated to. Shoutout to Daddylonglegs.

    Cheers!

+ 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