+ Reply to Thread
Results 1 to 26 of 26

Trying to nest SUMPRODUCT

  1. #1
    Forum Contributor
    Join Date
    06-21-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    191

    Trying to nest SUMPRODUCT

    Trying to sum payment data from a separate workbook, based upon values in the current workbook. I need to query Column O against a Named Range (DO) on the other book, but only where values in Column O aren't "See Detail" or "NA".

    I want to do something like:
    =SUMPRODUCT('Payment Data.xlsx'!DO=SUMPRODUCT(O9:O12<>"See Detail",O9:O12<>"NA"),'Payment Data.xlsx'!Amount)

    How can I get the second SUMPRODUCT to return an array of values? I also just tried straight matches with:
    =SUMPRODUCT('Payment Data.xlsx'!DO=O9:O12,'Payment Data.xlsx'!Amount)

    I thought it might have to do with the mix of text and numbers in O9:O12, so I limited it to just the numerical values in O11:O12, and I still can't get the sum of Amount that I want.

    Any thoughts or insight would be greatly appreciated!

  2. #2
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Trying to nest SUMPRODUCT

    So, I can't see exactly what you're looking at, but SUMPRODUCT doesn't return arrays. Why don't you just do one SUMPRODUCT and use parentheses to group as needed?

  3. #3
    Forum Contributor
    Join Date
    06-21-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    191

    Re: Trying to nest SUMPRODUCT

    More than willing to do that. Here's what O9:O12 looks like, and maybe you can help me figure out how to adjust SUMPRODUCT:
    See Detail
    NA
    14014555
    14012563

    Out of the above, I only want to match the numerical values, which isn't a big deal because the DO range won't include See Detail or NA anyway.

    Just doing: =SUMPRODUCT('Payment Data.xlsx'!DO=O9:O12,'Payment Data.xlsx'!Amount) returns #N/A, and it's the same with forcing True/False by doing: =SUMPRODUCT(--('Payment Data.xlsx'!DO=O9:O12),'Payment Data.xlsx'!Amount)
    Last edited by soberguy; 05-29-2014 at 03:22 PM.

  4. #4
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Trying to nest SUMPRODUCT

    I don't know what the DO range looks like, but this would this work?
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    I'm assuming the DO range is the same dimensions as O9:O12.

  5. #5
    Forum Contributor
    Join Date
    06-21-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    191

    Re: Trying to nest SUMPRODUCT

    Still returns #N/A.

    DO range is much larger. Single column, but over 15,000 rows.

  6. #6
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Trying to nest SUMPRODUCT

    That's the issue then. SUMPRODUCT expects ranges of the same dimensions. What exactly are you trying to accomplish?

  7. #7
    Forum Contributor
    Join Date
    06-21-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    191

    Re: Trying to nest SUMPRODUCT

    I've got payment data I need to sum. That's the named range Amount in the previously posted formula. I need to sum those areas where the ID number in named range DO matches the values in Column O of the current spreadsheet.

    This is horribly easy with a single ID, ie, Sumproduct(DO=O11, Amount)

    The issue here is that I have groups of values, and I'd like to collectively sum multiple IDs.

    Once this is sorted I'll add a Job Number check to it (also a defined range on the Payment sheet, column Q on the current sheet).

    Current worksheet arranged like:
    See Detail See Detail (Roll Up Sumproduct formula)
    NA Job Number One (no payment info because the ID is NA)
    14014555 Job Number 2 (this sumproduct works)
    14012563 Job Number 3 (this sumproduct works)

    The bolded area is where I need the help. It's easy enough to just sum(T9:T12), *but* the formulas in 11 and 12 won't be protected as they can be manually adjusted. Accordingly, I need to make sure that 11 and 12 (since 10 is blank or 0) match the total of the payments off the payment sheet.

    Hence why it made sense to me to try and do something like (Sumproduct(DO=(Sumproduct((O9:O12<>"See Detail)*(O9:O12<>"NA")),Amount)

  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: Trying to nest SUMPRODUCT

    To best describe or illustrate your problem you would be better off attaching a dummy workbook. The workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.


    Also, maybe take a look at the sumif() and sumifS() functions instead of sumproduct
    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

  9. #9
    Forum Contributor
    Join Date
    06-21-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    191

    Re: Trying to nest SUMPRODUCT

    Can't upload from work, and it won't import from Google Drive. Can I drop a link here to the file on my Drive account? And yes, it's all for Excel. Drive is just the only place I can easily put the file right now.

  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: Trying to nest SUMPRODUCT

    Many members are unable - or unwilling - to download files from file-hosting sites You seem to have mastered posting table here, so perhaps post a *small* table showing yoyr data a bit better?

  11. #11
    Forum Contributor
    Join Date
    06-21-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    191

    Re: Trying to nest SUMPRODUCT

    I understand the hesitation on file sharing sites. Hence I asked. Here's my underlying payment date (made in a super simple and user-friendly format):
    DO Job Number Amount
    14014555 H117GG10 75000
    14012563 H1211L30 5000
    14012563 H1211L30 5000
    14012563 H1211L30 5000
    14014288 H1177SLZ 905
    14014286 H1177SLZ 3250
    14014289 H1177SLZ 2845
    14014288 H1177SLZ 700
    14014286 H1177SLZ 6310
    14014289 H1177SLZ 3240
    14014288 H1177SLZ 835
    14014289 H1177SLZ 2375
    14014286 H1177SLZ 4495
    14014289 H1177SLZ 3375
    14014286 H1177SLZ 5055
    14014288 H1177SLZ 680
    14014289 H1177SLZ 2450
    14014288 H1177SLZ 810
    14014286 H1177SLZ 4085
    14014288 H1177SLZ 875
    14014289 H1177SLZ 2735
    14014286 H1177SLZ 5110
    14014288 H1177SLZ 405
    14014286 H1177SLZ 5220
    14014288 H1177SLZ 490
    14014286 H1177SLZ 4215
    14014289 H1177SLZ 2740
    14014289 H1177SLZ 3165
    14014288 H1177SLZ 1225
    14014286 H1177SLZ 4895

    And my roll up:
    Ref Doc ID Job Number Invoices Paid Thru 5-31 (Balance to YTD payment spreadsheet)
    See Detail See Detail 0
    NA H1211800 0
    14014555 H117GG10 75000
    14012563 H1211L30 15000
    See Detail See Detail
    14014286 H1177SLZ 42635
    14014289 H1177SLZ 22925
    14014288 H1177SLZ 6925
    On this table, numerical values in what would be Column C are the result of =SUMPRODUCT(DO=A5,JobNumber=B5,Amount)

    What I would LOVE is for C3 here to be able to SUMPRODUCT A5 and A6, with B5 and B6.

    Same thing with C8. While B9-11 all has the same job number, I only want charges to that job number where the ID matches A9:A11.

    I do hope that this makes a bit more sense.

  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: Trying to nest SUMPRODUCT

    OK not sure if I am on the right track here, but just so that we are on the same page, I am uploading my interpretation of your workbook (I understand you cannot dowlnoad, so let me know if Im close)

    I used SUMIF() to give the values you have in the 2nd table
    Attached Files Attached Files

  13. #13
    Forum Contributor
    Join Date
    06-21-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    191

    Re: Trying to nest SUMPRODUCT

    I can download, just not upload.

    And that's exactly what I've got right now. (Sidenote: sumif vs sumproduct, discuss)

    Ultimately, those formulas in I go in H. So let's pretend you did that.

    Those formulas won't be protected, so that hardcoded changes can be made. But what I'd love to do (and the purpose of this thread) is have, for example, H7 in your book do something like: Grab the 3 ID numbers in F, add up all the payments for the corresponding job codes in G, and compare that to the sum of H8:H10.

    Same thing for H2, though it would ignore F3 as it's NA.

    I've seen and done some really fun things in Excel. I can't wrap my head around this one though.

  14. #14
    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: Trying to nest SUMPRODUCT

    sumif() is far more efficient than sumproduct - you can use entire column ranges with sumif(), but doing that in sumproduct coulod cause your file to get really slow, and I put the formulas in I so you could compare I just wanted to make sure we are onthe same page, data/layout-wise

    What determines which doc refs or job numbers get grouped?

  15. #15
    Forum Contributor
    Join Date
    06-21-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    191

    Re: Trying to nest SUMPRODUCT

    Short story is there isn't much logic to it that would sense. Longer answer is that this is financial tracking for contract expenditures. We might have what we call a Master Agreement, which will group individual Doc Refs (one per Provider). A Doc Ref may have a single job number, or up to ten job numbers. There's absolutely no logic in the job numbers that I can figure out. It's a horrible system we're forced to use, and a format and layout that we can't deviate from. So far I've made a lot of things work really well, even if I have to get a little convoluted.

    In all, I've got 7 workbooks like this that will tie back to the single Payments workbook, and each of those 6 workbooks has ~140 rows of data.

    If need be, I can combine it all and create a helper spreadsheet in the Payments book. Like most of you fine folks, I hate helper columns.

    I just can't see any other way right now.

  16. #16
    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: Trying to nest SUMPRODUCT

    Like most of you fine folks, I hate helper columns.
    Actually I love helper columns, they can simplify so much

    Here is what I have so far.

    I put this in I2, copied down...
    =IF(F2="",I1+1,I1)

    Then in J2, copied down...
    =IF(F2="see detail",SUMIF($I$2:$I$10,I2,$H$2:$H$10),"")

  17. #17
    Forum Contributor
    Join Date
    06-21-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    191

    Re: Trying to nest SUMPRODUCT

    OK, now I have 0 in all I cells, and J2 and J7 show the total sum of the entirety of C.

    Where'd I go wrong?

  18. #18
    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: Trying to nest SUMPRODUCT

    I know this is not exactly ideal, but maybe we can refine it - IF this is heading to where you want to be....
    Attached Files Attached Files

  19. #19
    Forum Contributor
    Join Date
    06-21-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    191

    Re: Trying to nest SUMPRODUCT

    That's what I get for not pasting I all the way down and skipping that blank row, eh? I opened that file up and suddenly the light went on. Sly little genius, you are.

    I think I can use the heck out of a helper column like that. I really like that creative solution there. Now if I can just get myself to the point where I can see those solutions on my own...

  20. #20
    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: Trying to nest SUMPRODUCT

    hahaha comes with practice

  21. #21
    Forum Contributor
    Join Date
    06-21-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    191

    Re: Trying to nest SUMPRODUCT

    Still tinkering with the original idea. This little gem works: =SUMPRODUCT((--(A2:A31=F8))+(--(A2:A31=F9))+(--(A2:A31=F10)),C2:C31)

    Now if I could just set that dynamically. But I'm not sure I can without going through VBA.

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

    Re: Trying to nest SUMPRODUCT

    Quote Originally Posted by soberguy View Post
    =SUMPRODUCT((--(A2:A31=F8))+(--(A2:A31=F9))+(--(A2:A31=F10)),C2:C31)
    Here's another way to write that:

    =SUMPRODUCT(SUMIF(A2:A31,F8:F10,C2:C31))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  23. #23
    Forum Contributor
    Join Date
    06-21-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    191

    Re: Trying to nest SUMPRODUCT

    Good call, Tony. If you caught this before the edit, I am eating crow as we speak. If you didn't, there was no edit.

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

    Re: Trying to nest SUMPRODUCT

    Both of our formulas return the same result...

    Data Range
    A
    B
    C
    D
    E
    F
    1
    2
    1
    10
    60
    3
    39
    4
    2
    20
    5
    22
    6
    3
    30
    7
    83
    8
    3
    1
    9
    52
    2
    10
    46
    3
    11
    -----
    -----
    -----
    -----
    -----
    -----


    =SUMPRODUCT(SUMIF(A2:A31,F8:F10,C2:C31))

  25. #25
    Forum Contributor
    Join Date
    06-21-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    191

    Re: Trying to nest SUMPRODUCT

    Tony, you freaking nailed it. Absolutely perfect solution that works with a dynamic range (in lieu of F8:F10), and SUMIFS so I can use the job code as a criteria as well.

    Very well done!

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

    Re: Trying to nest SUMPRODUCT

    You're welcome. Thanks for the feedback!

+ 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. Too many nest ifs
    By s4shibly in forum Excel Formulas & Functions
    Replies: 19
    Last Post: 06-23-2013, 01:12 AM
  2. Replies: 10
    Last Post: 11-11-2010, 03:49 PM
  3. One Nest Too Many - Help!
    By SamuelT in forum Excel General
    Replies: 6
    Last Post: 09-23-2005, 07:05 PM
  4. how do I nest functions
    By Rainy in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-18-2005, 03:06 PM
  5. [SOLVED] 7+ Nest If's
    By Channing in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 01-22-2005, 05: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