Array SumProduct Average?

ClimoC

Well-known Member
Joined
Aug 21, 2009
Messages
584
Hi again all

Not sure where to start with this one, so I'll try to keep it brief.

We have two sets of cells on separate rows that contain lookups to a separate table for each row. These return some decimal values.

Name1Name2Name3Name4Name5
Table1 Lookup1.021.121.30.890.91
Table2 Lookup1.071.141.20.990.95

<tbody>
</tbody>

These are then multiplied by a percentage, using the same 'name' for a lookup; these are hard-written into the cells

Name1Name2Name3Name4Name5
(Total 100%)27%34%3%4%32%

<tbody>
</tbody>

Giving us 2 Product Rows. We then sum each row and pick the one that is the largest sum

Name1Name2Name3Name4Name5Sum of Row
0.27540.3808etcetcetc1.19
0.28890.3876etcetcetc1.17

<tbody>
</tbody>


Including the lookups by the name, is there a way to put this in a single array formula (even if it's wrapped in an If statement to pick the biggest one?)

Thanks
C
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Not sure i understand what you want. Maybe this...


A
B
C
D
E
F
G
H
I
J
K
L
1
Name1​
Name2​
Name3​
Name4​
Name5​
Name1​
Name2​
Name3​
Name4​
Name5​
2
Table1 Lookup​
1,02​
1,12​
1,3​
0,89​
0,91​
27%​
34%​
3%​
4%​
32%​
3
Table2 Lookup​
1,07​
1,14​
1,2​
0,99​
0,95​
4
5
Result (Max)​
6
1,0561​

<tbody>
</tbody>


Formula in A6
=MAX(MMULT(B2:F3*H2:L2,{1;1;1;1;1}))

Remark: I got different values for the sums of rows: 1.022 and 1.0561 (not 1.19 and 1.17 as in your post). So the largest sum is 1.0561.

Hope this helps

M.
 
Upvote 0
Thanks Marcelo

The figures I put in (1.19 and 1.17) were just examples (as I couldn't be bothered transcribing all the real data)

What you've kindly provided me with looks like it would remove the need for the extra 2 summary rows whcih are currently summed and ranked.

Is there a formula I'm forgetting about which could return the array values, B2:F2 and B3:F3 in your example? I was hoping some sort of sumproduct hybrid could spare all the work of generating the table rows as above.

Is it clearer if I word it like this?

Two arrays from two tables, using the same key (name) as a lookup, are multiplied against a third array. The totals of all the products in the two array*array are summed to see which one is bigger, and return that bigger value to a cell
 
Upvote 0
Is there a formula I'm forgetting about which could return the array values, B2:F2 and B3:F3 in your example? I was hoping some sort of sumproduct hybrid could spare all the work of generating the table rows as above.

Is it clearer if I word it like this?

We need more information.
How the arrays B2:F2 and B2:F3 are being generated? Could you provide the formulas and data sample?

M.
 
Upvote 0
Sorry. I don't know what's wrong with me. I'm a VB developer... I should really just write a function to do this all and return a value... I think I was just so intent on sticking to formulas for this one...
 
Upvote 0
Sorry. I don't know what's wrong with me. I'm a VB developer... I should really just write a function to do this all and return a value... I think I was just so intent on sticking to formulas for this one...

Probably a UDF (User Defined Function) can easily do the job. I was just curious if it was possible a solution using formulas ...

M.
 
Upvote 0
I think I'll just write the VBA function to do this, but if you're interested in solving it (possibly for others) then it's like this:

Array 1
ABCDE
1Name1Name2Name3Name4Name5
2=vlookup(A1,Sheet2!B43:P778,3,0)=vlookup(B1,Sheet2!B43:P778,3,0)=vlookup(C1,Sheet2!B43:P778,3,0)=vlookup(D1,Sheet2!B43:P778,3,0)=vlookup(E1,Sheet2!B43:P778,3,0)

<tbody>
</tbody>

Array 2

ABCDE
6Name1Name2Name3Name4Name5
7=vlookup(A6,Sheet3!B43:P778,3,0)=vlookup(B6,Sheet3!B43:P778,3,0)=vlookup(C6,Sheet3!B43:P778,3,0)=vlookup(D6,Sheet3!B43:P778,3,0)=vlookup(E6,Sheet3!B43:P778,3,0)


<tbody>
</tbody>

Array 3
ABCDE
11Name1Name2Name3Name4Name5
12=vlookup(A1,Sheet4!B3:O15,10,0)=vlookup(B1,Sheet4!B3:O15,10,0)=vlookup(C1,Sheet4!B3:O15,10,0)=vlookup(D1,Sheet4!B3:O15,10,0)=vlookup(E1,Sheet4!B3:O15,10,0)


<tbody>
</tbody>


Then we go:

ABCDEF
20=A2*A12=B2*B12=C2*C12=D2*D12=E2*E12=Sum(A20:E20)
21=A7*A12=B7*B12=C7*C12=D7*D12=E7*E12=Sum(A21:E21)

<tbody>
</tbody>


So that we can finally go:

=MAX(F20,F21)

That's the value that we need to get to, the Max one.
 
Upvote 0
I think I'll just write the VBA function to do this, but if you're interested in solving it (possibly for others)

Maybe something like this
An example using your data sample above but with the 3 tables in the same sheet


A
B
C
D
E
F
G
H
I
J
1
Names​
Table1​
Table2​
Table3​
2
Name1​
Name3​
1,3​
Name2​
1,14​
Name4​
4%​
3
Name2​
Name2​
1,12​
Name1​
1,07​
Name6​
0%​
4
Name3​
Name6​
0,88​
Name6​
1,2​
Name1​
27%​
5
Name4​
Name5​
0,91​
Name4​
0,99​
Name3​
3%​
6
Name5​
Name4​
0,89​
Name3​
1,2​
Name2​
34%​
7
Name1​
1,02​
Name5​
0,95​
Name5​
32%​
8
9
Max Formula​
10
1,0561​

<tbody>
</tbody>


Formula in A10
=MAX(SUMPRODUCT(SUMIF(C2:C7,A2:A6,D2:D7)*SUMIF(I2:I7,A2:A6,J2:J7)),SUMPRODUCT(SUMIF(F2:F7,A2:A6,G2:G7)*SUMIF(I2:I7,A2:A6,J2:J7)))

M.
 
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,614
Members
449,091
Latest member
gaurav_7829

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top