+ Reply to Thread
Results 1 to 10 of 10

Why is this formula giving incorrect data (SUMPRODUCT)?

  1. #1
    Registered User
    Join Date
    05-10-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    29

    Why is this formula giving incorrect data (SUMPRODUCT)?

    I have a formula that gives me a total of submissions in a particular month. It is the following, where column E is the date: =SUMPRODUCT((MONTH('Sheet1'!$E$2:$E$99)=1)+0)+SUMPRODUCT((MONTH('Sheet2'!$E$2:$E$100)=1)+0) -- January's total

    This formula works for all the months I already have it (starting in June of last year), but when I updated it for January (see above, by changing the MONTH formula), I am getting erroneous values, where the total is far too high. I do not know nor understand why this keeps happening. Any insight would be greatly appreciated.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Why is this formula giving incorrect data (SUMPRODUCT)?

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    If posting code please use code tags, see here.

  3. #3
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Why is this formula giving incorrect data (SUMPRODUCT)?

    Do you have blank cells? MONTH(A1) will return 1 if A1 is blank.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  4. #4
    Registered User
    Join Date
    05-10-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: Why is this formula giving incorrect data (SUMPRODUCT)?

    Quote Originally Posted by Izandol View Post
    Do you have blank cells? MONTH(A1) will return 1 if A1 is blank.
    I just realized this when auditing the formula. Do you know how I can avoid this error if the cell is blank?

  5. #5
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Why is this formula giving incorrect data (SUMPRODUCT)?

    You may use:
    =SUMPRODUCT((MONTH('Sheet1'!$E$2:$E$99)=1)*('Sheet1'!$E$2:$E$99<>""))+SUMPRODUCT((MONTH('Sheet2'!$E$2:$E$100)=1)*('Sheet2'!$E$2:$E$100<>""))

  6. #6
    Registered User
    Join Date
    05-10-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: Why is this formula giving incorrect data (SUMPRODUCT)?

    It did not work, as it caused a #NUM error for the dates that are already on the sheet.

  7. #7
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Why is this formula giving incorrect data (SUMPRODUCT)?

    I have tested this and it is working. May you provide a sample that shows this error?

  8. #8
    Registered User
    Join Date
    05-10-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    29

    Re: Why is this formula giving incorrect data (SUMPRODUCT)?

    Never mind. It did work (I just made a mistake in my formula by referencing the wrong column). Thank you so much! Could you possibly explain how the formula rectified the problem?

  9. #9
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Why is this formula giving incorrect data (SUMPRODUCT)?

    Certainly. Your section was:
    MONTH('Sheet1'!$E$2:$E$99)=1)
    which returns TRUE for all rows where month is 1, but this includes blank cell.
    ('Sheet1'!$E$2:$E$99<>"")
    returns TRUE for cells with some data and FALSE for blank cells
    (TRUE is 1 for mathematical purposes in Excel and FALSE is 0)
    Multiply these together and we have 1 for each row that month = 1 and cell is not blank (0 for all other rows). Then these are added to give count for the month.

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Why is this formula giving incorrect data (SUMPRODUCT)?

    Quote Originally Posted by Izandol View Post
    You may use:
    =SUMPRODUCT((MONTH('Sheet1'!$E$2:$E$99)=1)*('Sheet1'!$E$2:$E$99<>""))+SUMPRODUCT((MONTH('Sheet2'!$E$2:$E$100)=1)*('Sheet2'!$E$2:$E$100<>""))
    If the dates are all within the same year you can check the dates with a single test. For example, to check for dates in Jan 2014...

    Instead of using 2 conditional tests like this:

    =SUMPRODUCT((MONTH('Sheet1'!$E$2:$E$99)=1)*('Sheet1'!$E$2:$E$99<>""))

    We can use 1 conditional test like this:

    =SUMPRODUCT(--(TEXT('Sheet1'!$E$2:$E$99,"mmm yyyy")="Jan 2014"))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] ROUND formula giving incorrect result
    By Marvo in forum Excel General
    Replies: 11
    Last Post: 08-19-2012, 12:15 PM
  2. Mulitiplying in formula giving incorrect answer
    By oxicottin in forum Excel General
    Replies: 3
    Last Post: 12-20-2009, 10:00 PM
  3. Sumproduct formula not giving expected results
    By Shocked in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 09-30-2008, 03:12 PM
  4. Replies: 0
    Last Post: 09-23-2008, 02:03 PM
  5. Formula giving incorrect answer...
    By Jambruins in forum Excel General
    Replies: 3
    Last Post: 02-25-2005, 03:06 PM

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