+ Reply to Thread
Results 1 to 13 of 13

SUMPRODUCT based on YEAR, DATE or DATEVALUE

  1. #1
    Registered User
    Join Date
    05-30-2020
    Location
    SF Bay Area
    MS-Off Ver
    2010
    Posts
    6

    SUMPRODUCT based on YEAR, DATE or DATEVALUE

    This is probably going to be an easy one.

    I have read through several postings and tried to build a formula using SUMPRODUCT but its not working as expected. I am trying to sumproduct 2 columns based on the date value in a third column. I've tried using an embedded DATE, DATEVALUE and YEAR function but nothing seems to work right. I've attached an example of what I've tried so far. I'm trying to multiply the "Unit" column by the "Cost" column if the "Date" column value is from the year 2018. The output is not even close and i cant seem to get it to work right.

    Thanks in advance for all the help!
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: SUMPRODUCT based on YEAR, DATE or DATEVALUE

    Welcome to the forum.

    =SUMPRODUCT((YEAR(A2:A8)=2018*C2:C8<>"")*D2:D8)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    05-30-2020
    Location
    SF Bay Area
    MS-Off Ver
    2010
    Posts
    6

    Re: SUMPRODUCT based on YEAR, DATE or DATEVALUE

    Hi Ali...
    Just double checking the formula. I dont have anything in columns D, so I am assuming I would swap C for B and D for C, correct? Also, can you explain, briefly and hopefully plainly where I went wrong?

    Thanks!

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: SUMPRODUCT based on YEAR, DATE or DATEVALUE

    The formula I have given you is based on the attachment - I don’t know how that compares to your real workbook.

    For both criteria to be met, you need the AND operator *.

  5. #5
    Registered User
    Join Date
    05-30-2020
    Location
    SF Bay Area
    MS-Off Ver
    2010
    Posts
    6

    Re: SUMPRODUCT based on YEAR, DATE or DATEVALUE

    Ok, I'm not sure what happened when I attached the workbook but there it nothing in column D. So, I simply adjusted your formula to use columns A, B and C. That done the output is still wrong but there is progress. The output of the formula = 987.74, instead of the expected 51927.37 Based on the desired variable conditions being met, column A's year value is 2018 the following should be done: [(b2*c2)+(b3*c3)+(b4*c4)] equating to the expected $51K. What do you reckon is missing?

  6. #6
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: SUMPRODUCT based on YEAR, DATE or DATEVALUE

    D2 = year(a2)
    E2 = month(a2)
    F2 = B2*C2

    After that a pivot table.

    See the attached file.
    Last edited by oeldere; 05-30-2020 at 01:40 PM. Reason: f2 added
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  7. #7
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: SUMPRODUCT based on YEAR, DATE or DATEVALUE

    Please Login or Register  to view this content.
    note:
    =SUMPRODUCT(B2:B8,C2:C8,(YEAR(A2:A8=2018)))
    YEAR(A2:A8=2018) <>YEAR(A2:A8)=2018
    Ben Van Johnson

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: SUMPRODUCT based on YEAR, DATE or DATEVALUE

    It gave the 51000 result in your sample workbook for me.

  9. #9
    Registered User
    Join Date
    05-30-2020
    Location
    SF Bay Area
    MS-Off Ver
    2010
    Posts
    6

    Re: SUMPRODUCT based on YEAR, DATE or DATEVALUE

    Hi oeldere! Thanks for the response!

    The sample I provided is part of a much larger spreadsheet. So I'd like to avoid pivot tables and a fixed variable location if possible. Instead finding a working formula would be much better as I can update the formula easier than the entire worksheet.

  10. #10
    Registered User
    Join Date
    05-30-2020
    Location
    SF Bay Area
    MS-Off Ver
    2010
    Posts
    6

    Re: SUMPRODUCT based on YEAR, DATE or DATEVALUE

    Hi protonLeah! Thanks for the response!!

    The formula you provided worked!!! Now to make sure I understand how it works: you are using a boolean argument on column A and if that output is true the corresponding column b is multiplied to column c and then summed. That correct? If not, where do I have it wrong?

    Thanks again!

  11. #11
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: SUMPRODUCT based on YEAR, DATE or DATEVALUE

    @PR1M

    In that case you don't know the power of pivot table.

    It is easy to calculate new info, by just drag and drop.

    Of course, I don't mind that you use sumproduct. I used it a lot before I knew pivot table.

    After I know pivot table, I use Pivot Table a lot (instead of sumproduct).

  12. #12
    Registered User
    Join Date
    05-30-2020
    Location
    SF Bay Area
    MS-Off Ver
    2010
    Posts
    6

    Re: SUMPRODUCT based on YEAR, DATE or DATEVALUE

    oeldere

    I'm very aware of the power of pivot tables. I use them a lot in other scenarios. Its just in this specific case it wouldn't work right.

  13. #13
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: SUMPRODUCT based on YEAR, DATE or DATEVALUE

    "... you are using a boolean argument on column A and if that output is true the corresponding column b is multiplied to column c and then summed. That correct? ..." Yes

+ 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. Sumproduct Date Compare for Month and Year
    By missdeannamarie in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-08-2018, 04:13 PM
  2. [SOLVED] SumProduct or DateValue or CountIfs or something else?
    By Crackerdaq in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-22-2017, 11:16 AM
  3. [SOLVED] sumproduct to count year values in range based on another cell year value
    By mr_mango81 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-04-2017, 12:46 AM
  4. [SOLVED] sumproduct to sort by year to date
    By mmccra2858 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-29-2014, 10:17 AM
  5. [SOLVED] Sumproduct from date - 4 criteria (inc month & year)
    By Knawl in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-28-2014, 04:48 AM
  6. [SOLVED] Using SumProduct for dates inclusive of Year to Date, Month to date, Quarter to Date
    By cartica in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-26-2014, 04:22 PM
  7. Sumproduct Datevalue Problem
    By andyp161 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-09-2006, 11:15 AM

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