+ Reply to Thread
Results 1 to 24 of 24

SumProduct with different sized arrays

  1. #1
    Registered User
    Join Date
    06-26-2014
    Location
    Lansing, MI
    MS-Off Ver
    Office 2010
    Posts
    9

    SumProduct with different sized arrays

    I want to take select records from one sheet and sum only the matching records from another sheet, but the ranges are different sizes. As an example, in Sheet1, I want to select the codes with a "Rank" of "1", and total the "Cost" of those matching codes in Sheet2.

    Can anyone please assist? I need a non-VBA solution.
    Attached Files Attached Files

  2. #2
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: SumProduct with different sized arrays

    Use a helper column to pull the Rank from Sheet1 onto Sheet2; any Code without a Rank on Sheet1 returns an error.

    Then SUMIF(rank_range, 1, cost_range)

    That will sum all the costs with Rank = 1 (which implies ignoring costs without ranks).
    Attached Files Attached Files

  3. #3
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: SumProduct with different sized arrays

    Try

    =SUMPRODUCT(COUNTIFS(Sheet1!A2:A12,Sheet2!A2:A16,Sheet1!B2:B12,1),Sheet2!B2:B16)
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  4. #4
    Registered User
    Join Date
    06-26-2014
    Location
    Lansing, MI
    MS-Off Ver
    Office 2010
    Posts
    9

    Re: SumProduct with different sized arrays

    Thanks Ben, but this is just an simple example that I attached, adding a helper column isn't a viable options in the actual example I am trying to solve as the data sets are rather large and include multiple sheets. Any other ideas without a helper column?

  5. #5
    Registered User
    Join Date
    06-26-2014
    Location
    Lansing, MI
    MS-Off Ver
    Office 2010
    Posts
    9

    Re: SumProduct with different sized arrays

    Ace, that worked, I will try it with my real data and see if I get the same result. Thanks!

  6. #6
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: SumProduct with different sized arrays

    Quote Originally Posted by KBreeze15 View Post
    Any other ideas without a helper column?
    Mostly depends on whether there are other unmentioned constraints.

    Are the data ranges sorted? All / some / none?

    Is it possible that there are elements missing rowwise?
    For example:
    Range 1 = {1,2,3,4,5}
    Range 2 = {1,3,5}

    Do codes repeat? How should those be handled?

  7. #7
    Registered User
    Join Date
    06-26-2014
    Location
    Lansing, MI
    MS-Off Ver
    Office 2010
    Posts
    9

    Re: SumProduct with different sized arrays

    Ben, thanks again, Ace's solution worked, so I think I am all set. Awesome forum!

  8. #8
    Registered User
    Join Date
    06-26-2014
    Location
    Lansing, MI
    MS-Off Ver
    Office 2010
    Posts
    9

    Re: SumProduct with different sized arrays

    Ace, how would I sum on more than one Rank? Say, Rank=1 or Rank=2.

  9. #9
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: SumProduct with different sized arrays

    Try

    =SUMPRODUCT(COUNTIFS(Sheet1!A2:A12,Sheet2!A2:A16,Sheet1!B2:B12,"<=2"),Sheet2!B2:B16)

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,139

    Re: SumProduct with different sized arrays

    or use a cell reference instead of the "<=2" to define what rank you want to use
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  11. #11
    Registered User
    Join Date
    06-26-2014
    Location
    Lansing, MI
    MS-Off Ver
    Office 2010
    Posts
    9

    Re: SumProduct with different sized arrays

    Ace, this works for my original sample data, but my real data isn't quite the same, my apologies. I have updated my sample spreadsheet and attached to hopefully give a more realistic representation. In the new spreadsheet, I want to sum codes with ranks 11 and 22. In addition, I do not want to count the cost twice for a code if the code happens to have a rank of 11 and 22 in Sheet1. For example, code 1003 has a rank of both 11 and 22 in Sheet1, but when I sum 1003 in Sheet2, I only want to count it once (uniquely). Hope this makes sense, I really appreciate your help.
    Attached Files Attached Files

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

    Re: SumProduct with different sized arrays

    You get better help if you add the desired result in you sheet.

    Please also add the related cells.
    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.

  13. #13
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: SumProduct with different sized arrays

    Referring your sample sheet in post#11, one way to achieve this is.......

    Please Login or Register  to view this content.
    Does this help?
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  14. #14
    Registered User
    Join Date
    06-26-2014
    Location
    Lansing, MI
    MS-Off Ver
    Office 2010
    Posts
    9

    Re: SumProduct with different sized arrays

    It seems to count the first record twice? I uploaded a new file to show the desired result, which is on Sheet2.

  15. #15
    Registered User
    Join Date
    06-26-2014
    Location
    Lansing, MI
    MS-Off Ver
    Office 2010
    Posts
    9

    Re: SumProduct with different sized arrays

    Attached new file.
    Attached Files Attached Files

  16. #16
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: SumProduct with different sized arrays

    Hi,

    I have solved your problem....
    If you need any explanation, I will provide you...

    have a look...
    Attached Files Attached Files

  17. #17
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SumProduct with different sized arrays

    Hi,

    You just need to modify sktneer's solution slightly:

    =SUMPRODUCT(0+(MMULT(0+(ISNUMBER(MATCH(A2:A16&{11,22},Sheet1!A2:A17&Sheet1!B2:B17,0))),{1;1})>0),B2:B16)

    @sktneer Very nice idea with the &11 and &22, by the way.

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  18. #18
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: SumProduct with different sized arrays

    sorry bro,

    i interpreted your thread wrongly....

    but i am back with pin point solution...

    you just have to enter the rank...

    and it will provide the solution..

    for explanation just contact me..
    Attached Files Attached Files

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

    Re: SumProduct with different sized arrays

    When I sum your criteria I get 667.067.

    So please explain better.

  20. #20
    Registered User
    Join Date
    06-26-2014
    Location
    Lansing, MI
    MS-Off Ver
    Office 2010
    Posts
    9

    Re: SumProduct with different sized arrays

    XOR LX's solution (post #17) solved my issue, thanks for the replies.

  21. #21
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SumProduct with different sized arrays

    Quote Originally Posted by oeldere View Post
    When I sum your criteria I get 667.067.

    So please explain better.
    You haven't included the value for 1016 for some reason.

    Regards

  22. #22
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SumProduct with different sized arrays

    Quote Originally Posted by KBreeze15 View Post
    XOR LX's solution (post #17) solved my issue, thanks for the replies.
    You're welcome.

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

    Re: SumProduct with different sized arrays

    Thnaks Xor LX for the explanation in #21.

  24. #24
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SumProduct with different sized arrays

    Quote Originally Posted by oeldere View Post
    Thnaks Xor LX for the explanation in #21.
    No worries, my friend

+ 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, 2 arrays - do i need 3?
    By jinkeow in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 08-02-2013, 10:06 PM
  2. Sumproduct Arrays And / OR
    By Henry c in forum Excel General
    Replies: 6
    Last Post: 04-30-2010, 06:55 AM
  3. [SOLVED] Sumproduct arrays
    By L. Howard Kittle in forum Excel General
    Replies: 4
    Last Post: 04-11-2006, 08:20 AM
  4. Replies: 0
    Last Post: 04-13-2005, 12:06 PM
  5. Comparing Different Sized Arrays
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-20-2005, 01:06 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