+ Reply to Thread
Results 1 to 5 of 5

Use SUMPRODUCT, LEFT, and YEAR functions together

  1. #1
    Registered User
    Join Date
    10-22-2020
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    2020
    Posts
    2

    Use SUMPRODUCT, LEFT, and YEAR functions together

    Hello everyone!

    I would like use the SUMPRODUCT, LEFT, and the YEAR functions simultaneously. Column D contains data in the format '2017/01' (yyyy/mm), column E contains the amounts in $ that I would like to add together. Cell C2 contains the date in format 'dd/mm/yyyy'. I would like to have a function that adds the values in E if the year(C2) = left(D:D,4) and if month(C2) = right(D:D, 2)

    I wrote this function but unfortunately Excel returns 0: =SUMPRODUCT(--(LEFT(D:D,4)=YEAR(C2)), --(RIGHT(D:D,2)=MONTH(C2)),E:E). If I remove the YEAR/MONTH functions, the formula, which becomes =SUMPRODUCT(--(LEFT(D:D,4)=C2), --(RIGHT(D:D,2)=C2),E:E) works correctly. So, apparently the MONTH/YEAR functions are causing the error.

    Do you have any suggestion on how I could make the formula work?

    Thanks a lot in advance
    Attached Files Attached Files
    Last edited by excelmagic20; 10-22-2020 at 08:22 AM.

  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,476

    Re: Use SUMPRODUCT, LEFT, and YEAR functions together

    Welcome to the forum.

    There are instructions at the top of the page telling you how to attach your sample workbook.
    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
    10-22-2020
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    2020
    Posts
    2

    Re: Use SUMPRODUCT, LEFT, and YEAR functions together

    Thanks! And thanks for the suggestion I have now attached an Excel sample file

  4. #4
    Registered User
    Join Date
    10-21-2020
    Location
    pakistan
    MS-Off Ver
    2013
    Posts
    18

    Re: Use SUMPRODUCT, LEFT, and YEAR functions together

    Try this

    =sumproduct((left(d2:d20,4)=text(year(c2),0))*(right(d2:d20,2)=text(month(c2),"00"))*(e2:e20))

  5. #5
    Forum Contributor
    Join Date
    08-26-2016
    Location
    UK
    MS-Off Ver
    O365
    Posts
    260

    Re: Use SUMPRODUCT, LEFT, and YEAR functions together

    or:
    =SUMPRODUCT(--(D:D=TEXT(C2,"yyyy/mm")),E:E)
    but instead of using entire columns (heavy on resources) use the likes of:
    =SUMPRODUCT(--(D2:D19=TEXT(C2,"yyyy/mm")),E2:E19)

+ 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. Days left before end of contract year
    By thursday140 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-17-2019, 09:13 AM
  2. [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
  3. Time left in policy year
    By bryandecker in forum Excel Formulas & Functions
    Replies: 30
    Last Post: 03-22-2017, 04:09 PM
  4. [SOLVED] LEFT and SUMPRODUCT functions combined
    By DeZeeuw2 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 02-27-2014, 11:36 AM
  5. [SOLVED] Average a number into months left in year
    By jgryctz in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-14-2013, 02:50 PM
  6. Numbers of days left till the end of the year
    By Harrold in forum Excel General
    Replies: 2
    Last Post: 11-15-2011, 02:06 AM
  7. LEFT and RIGHT functions
    By shanemjo in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-11-2005, 08:30 AM

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