+ Reply to Thread
Results 1 to 11 of 11

SUMPRODUCT with two arrays and field selection

  1. #1
    Registered User
    Join Date
    06-25-2015
    Location
    PL
    MS-Off Ver
    2007
    Posts
    5

    SUMPRODUCT with two arrays and field selection

    Hello,

    I need to sum the product of two arrays.
    In the first array the column number to use in multiplication is known, however in the second one the column to select depends on value from another column in first array.

    Here is an example:

    Array A:

    Name Amount Final Period
    A 10 4 1
    A 20 4 2
    B 30 4 3

    Array B:

    Name 1 2 3
    A 0.5 0.2 0.3
    B 0.8 0.1 0.1

    Finally for row number 1 in Array A i need to find corresponding value in Array B (matching Name and column header = Final - Period from Array A) and multiply it by Amount from Array A.
    At the end the function should return a sum of all calculations, which for the example above is: 10 * ArrayB(A,3) + 20 * ArrayB(A,2) + 30 * ArrayB(B,1).

    Is it possible to use standard formulas and functions to receive that?

    Looking forward for your help

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: SUMPRODUCT with two arrays and field selection

    Can you clarify a little more? So would that final formula simplify to
    =10*(0.3) + 20*(0.2) + 30*(0.8)?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    06-25-2015
    Location
    PL
    MS-Off Ver
    2007
    Posts
    5

    Re: SUMPRODUCT with two arrays and field selection

    Quote Originally Posted by ChemistB View Post
    Can you clarify a little more? So would that final formula simplify to
    =10*(0.3) + 20*(0.2) + 30*(0.8)?
    That's right - final result would be as quoted

  4. #4
    Registered User
    Join Date
    06-25-2015
    Location
    PL
    MS-Off Ver
    2007
    Posts
    5

    Re: SUMPRODUCT with two arrays and field selection

    Ok, I am one step further with the following formula:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Unfortunately I am stuck again. Instead of 10*(0.3) + 20*(0.2) + 30*(0.8) the only result I get is 10*0.3 + 20*0.3 + 30*0.3 so those two matches in index are not moving properly

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

    Re: SUMPRODUCT with two arrays and field selection

    =REPT(,1,000,000,000,000,000,000,000)

    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: SUMPRODUCT with two arrays and field selection

    In Array A, at the end, add this formula:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    where $M$1:$P$21 is table of Array B.

    then you just SUM that column
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,199

    Re: SUMPRODUCT with two arrays and field selection

    See attached
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    06-25-2015
    Location
    PL
    MS-Off Ver
    2007
    Posts
    5

    Re: SUMPRODUCT with two arrays and field selection

    Thank you Guys.

    The question is - is it possible to do the calculations and sum those values in the single cell? I mean with the array formula?

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,199

    Re: SUMPRODUCT with two arrays and field selection

    This simply adds my 3 formulae together:

    =INDEX($B$8:$D$9,MATCH($A2,$A$8:$A$9,0),MATCH($C2-$D2,$B$7:$D$7,0))*$B2+INDEX($B$8:$D$9,MATCH($A3,$A$8:$A$9,0),MATCH($C3-$D3,$B$7:$D$7,0))*$B3+INDEX($B$8:$D$9,MATCH($A4,$A$8:$A$9,0),MATCH($C4-$D4,$B$7:$D$7,0))*$B4

  10. #10
    Registered User
    Join Date
    06-25-2015
    Location
    PL
    MS-Off Ver
    2007
    Posts
    5

    Re: SUMPRODUCT with two arrays and field selection

    Quote Originally Posted by JohnTopley View Post
    This simply adds my 3 formulae together:

    =INDEX($B$8:$D$9,MATCH($A2,$A$8:$A$9,0),MATCH($C2-$D2,$B$7:$D$7,0))*$B2+INDEX($B$8:$D$9,MATCH($A3,$A$8:$A$9,0),MATCH($C3-$D3,$B$7:$D$7,0))*$B3+INDEX($B$8:$D$9,MATCH($A4,$A$8:$A$9,0),MATCH($C4-$D4,$B$7:$D$7,0))*$B4
    Having 1000 rows to sum would be problematic in this case I guess...

  11. #11
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: SUMPRODUCT with two arrays and field selection

    Any array will be problematic (if exist).
    Adding one more column is much better in this case.
    You can hide it if you want

+ 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] Ranges in selection and arrays
    By fgq in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-19-2013, 01:07 PM
  2. Sumproduct, 2 arrays - do i need 3?
    By jinkeow in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 08-02-2013, 10:06 PM
  3. [SOLVED] Last Cell Selection using Arrays
    By plasma33 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-10-2012, 06:16 AM
  4. Sumproduct Arrays And / OR
    By Henry c in forum Excel General
    Replies: 6
    Last Post: 04-30-2010, 06:55 AM
  5. [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