Closed Thread
Results 1 to 12 of 12

Sumproduct with Arrays of Different Sizes

  1. #1
    Registered User
    Join Date
    03-30-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    12

    Sumproduct with Arrays of Different Sizes

    I would like to use sumproduct with ranges of different sizes by padding the smaller array with zeros. Any suggestions?

    For example, if the first array is always a fixed array with the following values:
    10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20

    and the second array can vary in length, with example values:
    1, 2, 3

    I would like a function that uses sumproduct to return the result: 116 (=0*10+0*11+0*12+...+1*18+2*19+3*20)

    I think the real question here might be how to pad an array with a dynamic number of zeros...

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Sumproduct with Arrays of Different Sizes

    hi jglassmanba, i think u need to provide us the full picture so that we can better advise. provide us a file so that we can see how we can link the 0s.

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: Sumproduct with Arrays of Different Sizes

    without full context, here is a comment. if you keep the sizes of the two ranges the same, SUMPRODUCT will supplant blanks with zeroes automatically. isn't that a desired behaviour?

    i see in your example that you are looking to pad zeroes to the top of the list, rather than bottom; is it just an example, or your real requirement?
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

  4. #4
    Registered User
    Join Date
    03-30-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Sumproduct with Arrays of Different Sizes

    Here is a still simplified but very realistic version of what I'm trying to do.

    The attached excel spreadsheet has two input tables:
    - One is a table of the expected percentage of people who are still alive at the end of age X, from 107 to 0 (descending order)
    - The second is a table of the number of people born in each year, from 2010 to 2055

    There is one output table:
    - The total year-end living population of people born since 2010, for every year from 2010 to 2055

    I have completed three of the blanks of the output table, but would like a methodology to complete the rest. I can only use excel functions, i.e. only non-VBA solutions.

    Thanks in advance!
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-30-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Sumproduct with Arrays of Different Sizes

    Solution attached.

  6. #6
    Registered User
    Join Date
    05-24-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Sumproduct with Arrays of Different Sizes

    I'm trying to do a similar thing, can you do this without putting the cumulative survival rate from the bottom up. My problem, specifically deals with oil and gas production by year and wells drilled in past years.

    Very simplified, but this is essentially the problem:


    Wells drilled
    2000 5
    2001 4
    2002 3
    2003 2
    2004 1
    2005 0

    Each well produces:

    10 bbl - y1
    8 bbl - y2
    6 bbl - y3
    4 bbl - y4
    2 bbl - y5

    2002 for example, I want 3 wells producing 10 bbl, 4 wells producing 8 bbl, and 5 wells producing 6 bbl. I've got the sumproduct from the earlier implemented, but I get the result of 3 wells producing 10 bbl, but 2 wells producing 8 bbl, (2003 instead of 2001) and 1 well producing 6 bbl. Both columns and height are set as 3, but instead of going up to my reference (2000) my offset is going down, is there any way to correct this without flipping my data?

  7. #7
    Registered User
    Join Date
    03-30-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Sumproduct with Arrays of Different Sizes

    That's a great question, as I initially dealt with the same issue. In my data set, I had a column with ascending data like what you showed. I needed to (a) transpose the data to put it into a row and (b) reverse the data so it was in descending order. I used the following array formula:

    {=TRANSPOSE(N(OFFSET($H$28:$H$63,ROWS($C$28:$C$63)-(ROW($C$28:$C$63)-ROW($C$28)+1),0,1,1)))}

    Column H had my equivalent to your 'bbl' data in rows 28-63; column C had my 'years' data

    Once I had created this new row, I used the method from my previous post. It should be possible, albeit cumbersome, to combine these two operations into a single calculation.

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Sumproduct with Arrays of Different Sizes

    Hello jglassmanba,

    for your original problem you could use this formula in H2 copied down

    =SUMPRODUCT(G$2:G2,OFFSET(C$109,0,0,-ROWS(G$2:G2)))
    Audere est facere

  9. #9
    Registered User
    Join Date
    03-30-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Sumproduct with Arrays of Different Sizes

    Oh cool, I wouldn't have thought of using a negative height/width. Thank you!

  10. #10
    Registered User
    Join Date
    09-04-2018
    Location
    Monterrey, Mexico
    MS-Off Ver
    2018
    Posts
    1

    Re: Sumproduct with Arrays of Different Sizes

    Hi, Did you ever solve this problem?

    Thanks
    Ezzy

  11. #11
    Registered User
    Join Date
    06-09-2021
    Location
    Colorado
    MS-Off Ver
    365
    Posts
    2

    Post Re: Sumproduct with Arrays of Different Sizes

    Hi! I'm new to the forum and am having a problem when trying to multiply arrays of differing sizes too. I will post a file showing the problem.

    But... basically, I have a file with several line items (as many as a few hundred) that each have individual weights (hours of effort estimated for each). Each of these line items follow the same process steps from start to finish (columns), with each of these steps weighted for earnings. Each line item has a date in the intersection between the line and the column containing the process step. What I need to do: for all line items that have a date <= a status date in each column, sumproduct (earnings weight [at top of columns] * weighted effort [hours on each line]) then divide that value by the total effort (sum of the effort on all lines).

    I used brute force in the past (starting on line 20 and following, columns C, D, and E ...

    =(($I$44*(SUMIF($I$46:$I$314,"<="&$B325,$G$46:$G$314)))+($J$44*(SUMIF($J$46:$J$314,"<="&$B325,$G$46:$G$314)))+($K$44*(SUMIF($K$46:$K$314,"<="&$B325,$G$46:$G$314)))+($L$44*(SUMIF($L$46:$L$314,"<="&$B325,$G$46:$G$314)))+($M$44*(SUMIF($M$46:$M$314,"<="&$B325,$G$46:$G$314)))+($N$44*(SUMIF($N$46:$N$314,"<="&$B325,$G$46:$G$314)))+($O$44*(SUMIF($O$46:$O$314,"<="&$B325,$G$46:$G$314))))/$G$315

    but would very much like to find out how to perform these calculations in a more elegant way. MMULT doesn't work because I may have 300 line items and 10 columns, which violates the MMULT array rules. It also constrains how many process steps (columns) can be used since I have to manually adjust each formula to accommodate additional columns... would love to be able to insert additional columns as needed.
    Attached Files Attached Files

  12. #12
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,372

    Re: Sumproduct with Arrays of Different Sizes

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    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.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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