+ Reply to Thread
Results 1 to 17 of 17

SUMPRODUCT with dynamic arrays

  1. #1
    Registered User
    Join Date
    11-23-2017
    Location
    Dubai
    MS-Off Ver
    MS 365 version 2208
    Posts
    13

    SUMPRODUCT with dynamic arrays

    I have 2 arrays.
    1st array has 10 rows and 5 columns The row labels aren't unique.
    2nd array has 10 rows with the same labels as 1st array but has only 1 column.
    Now my output table has 4 rows which are unique labels from the 1st 2 arrays and 5 columns with same headers as 1st row. I need to get a sumproduct of 1st array and 2nd array. I need a dynamic formula so that 1 formula in the 1st cell gives results for the whole table.
    I have given it a try in the attached excel (Cell C17), however, it's giving me value errors.

    =MAKEARRAY(COUNTA(B17#), COUNTA(C16#), LAMBDA(name,subject, SUMPRODUCT(J4# * (I4# = INDEX(B17#, name)), C4# * (B4# = INDEX(B17#, name)) * (C3# = INDEX(C16#, subject)))))
    Attached Files Attached Files
    Last edited by Joel Chacko; 07-06-2023 at 02:06 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,978

    Re: SUMPRODUCT with dynamic arrays

    Are you still using Excel 2013? MAKEARRAY is a 365 function - please update your forum profile.
    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
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: SUMPRODUCT with dynamic arrays

    C17:
    Please Login or Register  to view this content.
    Does it work?
    Quang PT

  4. #4
    Registered User
    Join Date
    11-23-2017
    Location
    Dubai
    MS-Off Ver
    MS 365 version 2208
    Posts
    13

    Re: SUMPRODUCT with dynamic arrays

    No. This is not what am looking for. As i said, i need a dynamic formula in Cell C17 which populates value for the whole table (C17:G22). Your formula will work if the formula is dragged to all the cells.

  5. #5
    Registered User
    Join Date
    11-23-2017
    Location
    Dubai
    MS-Off Ver
    MS 365 version 2208
    Posts
    13

    Re: SUMPRODUCT with dynamic arrays

    Yes. I am using Microsoft 365. Not sure how to update it in the forum profile.

  6. #6
    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,978

    Re: SUMPRODUCT with dynamic arrays

    See below:
    Attached Images Attached Images

  7. #7
    Registered User
    Join Date
    11-23-2017
    Location
    Dubai
    MS-Off Ver
    MS 365 version 2208
    Posts
    13

    Re: SUMPRODUCT with dynamic arrays

    Got it. Thanks.

    Do we have a solution for the query?

  8. #8
    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,978

    Re: SUMPRODUCT with dynamic arrays

    Patience, please!

  9. #9
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,005

    Re: SUMPRODUCT with dynamic arrays

    try this

    =MAKEARRAY(COUNTA(B17#), COUNTA(C16#), LAMBDA(name,subject, SUMPRODUCT(J4# * (I4# = INDEX(B17#, name))*(C4# * (B4# = INDEX(B17#, name)) * (C3# = INDEX(C16#, subject))))))

    PS. Thanks @Ali, I forgot to modify my test formula.
    Last edited by windknife; 07-06-2023 at 03:45 AM.

  10. #10
    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,978

    Re: SUMPRODUCT with dynamic arrays

    That returns 625 for every cell.

    But this seems to work:

    =MAKEARRAY(COUNTA(B17#), COUNTA(C16#), LAMBDA(name,subject, SUMPRODUCT(J4# * (I4# = INDEX(B17#, name))*(C4# * (B4# = INDEX(B17#, name)) * (C3# = INDEX(C16#, 1, subject))))))

  11. #11
    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,978

    Re: SUMPRODUCT with dynamic arrays

    And this will generate the whole table:

    =LET(r,UNIQUE(B3:B13),c,C3#,HSTACK(r,VSTACK(c,MAKEARRAY(COUNTA(B17#),COUNTA(C16#),LAMBDA(name,subject,SUMPRODUCT(J4#*(I4#=INDEX(B17#,name))*(C4#*(B4#=INDEX(B17#,name))*(C3#=INDEX(C16#,1,subject)))))))))

    PS. Thanks @Ali, I forgot to modify my test formula.
    You're welcome! I had just almost arrived at the same solution myself.
    Attached Files Attached Files
    Last edited by AliGW; 07-06-2023 at 03:50 AM. Reason: Workbook added.

  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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,978

    Re: SUMPRODUCT with dynamic arrays

    Solutions seen.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

  13. #13
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: SUMPRODUCT with dynamic arrays

    Please try

    =MMULT(N(B17#=TOROW(B4#)),C4#*J4#)
    Attached Files Attached Files

  14. #14
    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,064

    Re: SUMPRODUCT with dynamic arrays

    LoL. Far better than my effort, which was:

    =DROP(REDUCE(0,B17#,LAMBDA(y,z,VSTACK(y,BYCOL(IF(B4#=z,C4#*J4#,0),LAMBDA(x,SUM(x)))))),1)
    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.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  15. #15
    Registered User
    Join Date
    11-23-2017
    Location
    Dubai
    MS-Off Ver
    MS 365 version 2208
    Posts
    13

    Re: SUMPRODUCT with dynamic arrays

    Thanks. I got what i was looking for. Also, you provided alternative formulas. Good learning for me. thanks again.
    Last edited by AliGW; 07-06-2023 at 05:43 AM.

  16. #16
    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,978

    Re: SUMPRODUCT with dynamic arrays

    Glad to have helped.

  17. #17
    Registered User
    Join Date
    12-01-2020
    Location
    singapore
    MS-Off Ver
    MS2016
    Posts
    35

    Re: SUMPRODUCT with dynamic arrays

    This problem is very similar to the problem I encountered at work

    If this row changes the title, POST#13 Bo_Ry and POST#14 Glenn Kennedy how can I modify the formula to execute smoothly at Row 16 ?
    Attached Files Attached Files

+ 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. [SOLVED] Sumproduct error using 2 arrays
    By zepharoz in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-27-2022, 03:32 PM
  2. Dynamic Arrays, Dynamic Drop down list, Filters and multiple rows
    By Big_Kev007 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-09-2020, 06:35 AM
  3. [SOLVED] Sumproduct with 2 arrays
    By rpinxt in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-05-2015, 05:12 AM
  4. Sumproduct, 2 arrays - do i need 3?
    By jinkeow in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 08-02-2013, 10:06 PM
  5. [SOLVED] SUMPRODUCT and different arrays
    By rodich in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 05-09-2013, 07:02 AM
  6. Sumproduct Arrays And / OR
    By Henry c in forum Excel General
    Replies: 6
    Last Post: 04-30-2010, 06:55 AM
  7. [SOLVED] Sumproduct arrays
    By L. Howard Kittle in forum Excel General
    Replies: 4
    Last Post: 04-11-2006, 08:20 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