+ Reply to Thread
Results 1 to 12 of 12

Sumif or Sumproduct function?

  1. #1
    Registered User
    Join Date
    02-21-2014
    Location
    Connecticut, U.S.A.
    MS-Off Ver
    Excel 2010
    Posts
    52

    Sumif or Sumproduct function?

    Hi there - I'm trying to use a helper column in my table that will return the sum of customer sales for a given year, on the first occurrence of that customer in that given year. Here is my table layout:

    Posting Date Customer No. Sale Amount Year Yearly Sales
    1/1/18 CUST100 $100 2018 $1,600
    1/5/18 CUST100 $300 2018 $0
    1/8/18 CUST100 $500 2018 $0
    1/11/18 CUST100 $700 2018 $0
    12/31/17 CUST100 $50 2017 $525
    11/15/17 CUST100 $75 2017 $0
    12/11/17 CUST100 $400 2017 $0

    As you can see, for 2018 there are 4 entries totaling $1,600 worth of sales. I want to return that total on the first line where the Customer appears for that given year. So $1,600 would show on the first line for CUST100 in 2018, and $0 will show for the remainder of the entries for that customer during the same year. The reason I need to do this is so that in my pivot table I can show total sales for a customer year over year, without inflating the numbers. I'm open to suggestions for how to make this more elegant.

    Thank you.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Sumif or Sumproduct function?

    You should be able to show total sales for a customer year over year in a pivot table without adding an extra column here. If you provide your Excel file I can demonstrate what I mean.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: Sumif or Sumproduct function?

    Why don't you just create your Pivot Table with Customer No. and Year in the Row Labels box and Sum of Sales Amount in the Values box? I can't see the need for a helper column.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Registered User
    Join Date
    02-21-2014
    Location
    Connecticut, U.S.A.
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Sumif or Sumproduct function?

    Sorry gents - I forgot a critical piece. Once I have Sales by Year side by side, I was going to create a calculated field in the pivot table to subtract the difference in sales Year over Year.

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Sumif or Sumproduct function?

    If you really want a formula. put this in E2...
    =SUMIFS($C$2:$C$8,$B$2:$B$8,B2,$A$2:$A$8,">=1/1/"&YEAR(A2),$A$2:$A$8,"<=12/31/"&YEAR(A2))
    then put this below and copy down...
    =IF(AND(YEAR(A3)=YEAR(A2),B3=B2),"",SUMIFS($C$2:$C$8,$B$2:$B$8,B3,$A$2:$A$8,">=1/1/"&YEAR(A3),$A$2:$A$8,"<=12/31/"&YEAR(A3)))

    (I could probably figure out how to make it all the same formula, that that works
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  6. #6
    Registered User
    Join Date
    02-21-2014
    Location
    Connecticut, U.S.A.
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Sumif or Sumproduct function?

    Thanks for answering my question, guys. I found the solution I was looking for via a pivot table technique. Found it here: https://www.mrexcel.com/forum/excel-...and-total.html

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: Sumif or Sumproduct function?

    You're welcome.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Sumif or Sumproduct function?

    Im happy you got where you wanted to be

  9. #9
    Valued Forum Contributor jtakw's Avatar
    Join Date
    05-05-2018
    Location
    CA, USA
    MS-Off Ver
    2016
    Posts
    668

    Re: Sumif or Sumproduct function?

    Hi,

    Was cross posted without notice at mrexcel: /forum/excel-questions/1056926-sumif-sumproduct-function.html

  10. #10
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Sumif or Sumproduct function?

    Thanks for sharing that with us

    (I hope you shared this 1 with then, too?)

  11. #11
    Valued Forum Contributor jtakw's Avatar
    Join Date
    05-05-2018
    Location
    CA, USA
    MS-Off Ver
    2016
    Posts
    668

    Re: Sumif or Sumproduct function?

    Quote Originally Posted by FDibbins View Post
    Thanks for sharing that with us

    (I hope you shared this 1 with then, too?)
    Yes I did, Ford. (Hope you're doing well)

    Couldn't post the entire url above, not enough posts here yet.

  12. #12
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Sumif or Sumproduct function?

    Understood, no problem - and yes, I am doing better each day, thanks

+ 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. Excel Function Sumif/ Sumifs or Sumproduct
    By Sontu in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-25-2018, 07:39 PM
  2. Replies: 2
    Last Post: 06-21-2017, 06:32 PM
  3. Sumproduct within a sumif function
    By Steverizer in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-15-2013, 06:20 PM
  4. Replies: 0
    Last Post: 08-17-2012, 02:02 PM
  5. Combining SUMIF with SUMPRODUCT function
    By John Elford in forum Excel General
    Replies: 4
    Last Post: 11-04-2010, 06:13 PM
  6. [SOLVED] SUMIF Function Inside SUMPRODUCT Function
    By Abdul Waheed in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 09-19-2005, 12:05 PM
  7. [SOLVED] HELP!!!! sumif or sumproduct ??? :(
    By Wally in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-31-2005, 09:05 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