Sumproduct with different array sizes

jkj115

New Member
Joined
Dec 16, 2011
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I have two sets of data. I want to multiply the data in one set by the data in the other if the store name matches. My issue is that one set of data will be missing some of the stores from the first set. I want to be able to calculate the total without calculating the individual items.

This will make more sense in the attachment. I am thinking maybe an array formula but I really don't know how to work with those that well.

Different Size Arrays.xlsx
DEFGHIJKLMNOP
3Units Sold
4
5StoreMonth 1Month 2Month 3Month 4Month 5
6Store 148385
7Store 245843
8Store 31041074
9Store 4911059
10Store 535875
11Store 677252
12Store 713660
13Store 824542
14Store 915522
15Store 107910710
16
17Price per Unit
18StoreMonth 1Month 2Month 3Month 4Month 5
19Store 1$ 23.00$ 27.00$ 27.00$ 28.00$ 26.00
20Store 2$ 22.00$ 36.00$ 32.00$ 23.00$ 37.00
21Store 3$ 40.00$ 40.00$ 36.00$ 25.00$ 33.00
22Store 5$ 23.00$ 27.00$ 34.00$ 39.00$ 21.00
23Store 6$ 39.00$ 24.00$ 22.00$ 25.00$ 34.00
24Store 7$ 34.00$ 38.00$ 22.00$ 32.00$ 34.00
25Store 9$ 30.00$ 28.00$ 34.00$ 22.00$ 32.00
26Store 10$ 33.00$ 23.00$ 33.00$ 23.00$ 26.00
27
28
29Intended Result
30StoreMonth 1Month 2Month 3Month 4Month 5
31Store 1$ 92.00$ 216.00$ 81.00$ 224.00$ 130.00
32Store 2$ 88.00$ 180.00$ 256.00$ 92.00$ 111.00
33Store 3$ 400.00$ 160.00$ 360.00$ 175.00$ 132.00
34Store 4#N/A#N/A#N/A#N/A#N/A
35Store 5$ 69.00$ 135.00$ 272.00$ 273.00$ 105.00
36Store 6$ 273.00$ 168.00$ 44.00$ 125.00$ 68.00
37Store 7$ 34.00$ 114.00$ 132.00$ 192.00$ -
38Store 8#N/A#N/A#N/A#N/A#N/A
39Store 9$ 30.00$ 140.00$ 170.00$ 44.00$ 64.00
40Store 10$ 231.00$ 207.00$ 330.00$ 161.00$ 260.00
41
42Total$ 1,217.00$ 1,320.00$ 1,645.00$ 1,286.00$ 870.00<need to get this without calculating individual store data
Sheet1
Cell Formulas
RangeFormula
E31:I40E31=VLOOKUP($D31,$D$6:$I$15,COLUMNS($D$6:E$15),FALSE)*VLOOKUP($D31,$D$19:$I$26,COLUMNS($D$19:E$26),FALSE)
E42:I42E42=SUM(E31:E33,E35:E37,E39:E40)
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
What version of Excel are you using? Please update your account profile to show that, as the answer influences the solution.
 
Upvote 0
Something like this can be used to handle missing items and rows/columns that are not ordered:
MrExcel_20240104.xlsx
DEFGHI
3Units Sold
4
5StoreMonth 1Month 2Month 3Month 4Month 5
6Store 148385
7Store 245843
8Store 31041074
9Store 4911059
10Store 535875
11Store 677252
12Store 713660
13Store 824542
14Store 915522
15Store 107910710
16
17Price per Unit
18StoreMonth 1Month 4Month 5Month 2Month 3
19Store 12328262727
20Store 22223373632
21Store 93022322834
22Store 52339212734
23Store 73432343822
24Store 63925342422
25Store 103323262333
26Store 34025334036
27
28Month 1Month 2Month 3Month 4Month 5
291217132016451286870
Sheet1
Cell Formulas
RangeFormula
E29:I29E29=SUMPRODUCT(INDEX($E$6:$I$15,,MATCH(E28,$E$5:$I$5,0)),IF(ISNUMBER(MATCH($D$6:$D$15,$D$19:$D$26,0)),INDEX($E$19:$I$26,MATCH($D$6:$D$15,$D$19:$D$26,0),MATCH(E28,$E$18:$I$18,0)),0))
 
Upvote 0
What version of Excel are you using? Please update your account profile to show that, as the answer influences the solution.
Microsoft® Excel® for Microsoft 365 MSO (Version 2312 Build 16.0.17126.20078) 64-bit
 
Upvote 0
Microsoft® Excel® for Microsoft 365

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
Another option:

Libro1
ABCDEF
1Units Sold
2
3StoreMonth 1Month 2Month 3Month 4Month 5
4Store 148385
5Store 245843
6Store 31041074
7Store 4911059
8Store 535875
9Store 677252
10Store 713660
11Store 824542
12Store 915522
13Store 107910710
14
15Price per Unit
16StoreMonth 1Month 2Month 3Month 4Month 5
17Store 12327272826
18Store 22236322337
19Store 34040362533
20Store 52327343921
21Store 63924222534
22Store 73438223234
23Store 93028342232
24Store 103323332326
25
26
27Intended Result
28StoreMonth 1Month 2Month 3Month 4Month 5
29Total1217132016451286870
Hoja1
Cell Formulas
RangeFormula
B29:F29B29=SUM(BYROW($A$4:$A$13,LAMBDA(s,XLOOKUP(s,$A$17:$A$25,B$17:B$25,0,0)))*B$4:B$13)
 
Upvote 0
thanks so much. If I wanted to make this just a sumif instead of multiplying the two sets together, how could I adjust the formula? For example, if the Units Sold is >5, sum all of the data in the second table for those stores with >5 sold (this is for a slightly diff data set so ignore the fact that that would not make sense for price per unit).
 
Upvote 0
You mean the same sum of multiplication but filter the first (units sold) table first on certain condition?
 
Upvote 0
I'm assuming you want a SUMIF of only the 2nd table using the first table as a filter:
MrExcel_20240104.xlsx
ABCDEF
1Units Sold
2
3StoreMonth 1Month 2Month 3Month 4Month 5
4Store 148385
5Store 245843
6Store 31041074
7Store 4911059
8Store 535875
9Store 677252
10Store 713660
11Store 824542
12Store 915522
13Store 107910710
14
15Price per Unit
16StoreMonth 1Month 2Month 3Month 4Month 5
17Store 12327272826
18Store 22236322337
19Store 34040362533
20Store 52327343921
21Store 63924222534
22Store 73438223234
23Store 93028342232
24Store 103323332326
25
26
27Intended Result
28StoreMonth 1Month 2Month 3Month 4Month 5
29Total1217132016451286870
30Sum 2nd Question1127415714726
Sheet2
Cell Formulas
RangeFormula
B29:F29B29=SUM(BYROW($A$4:$A$13,LAMBDA(s,XLOOKUP(s,$A$17:$A$25,B$17:B$25,0,0)))*B$4:B$13)
B30:F30B30=SUM(BYROW(FILTER($A$4:$A$13,B$4:B$13>5),LAMBDA(r,SUMIF($A$17:$A$24,r,B$17:B$24))))
 
Upvote 0
How about this?:

Book1
ABCDEF
1Units Sold
2
3StoreMonth 1Month 2Month 3Month 4Month 5
4Store 148385
5Store 245843
6Store 31041074
7Store 4911059
8Store 535875
9Store 677252
10Store 713660
11Store 824542
12Store 915522
13Store 107910710
14
15Price per Unit
16StoreMonth 1Month 2Month 3Month 4Month 5
17Store 12327272826
18Store 22236322337
19Store 34040362533
20Store 52327343921
21Store 63924222534
22Store 73438223234
23Store 93028342232
24Store 103323332326
25
26
27Intended Result
28StoreMonth 1Month 2Month 3Month 4Month 5
29Total1217132016451286870
30Filtered total90459113501025260
Sheet1
Cell Formulas
RangeFormula
B29:F29B29=SUM(BYROW($A$4:$A$13,LAMBDA(s,XLOOKUP(s,$A$17:$A$25,B$17:B$25,0,0)))*B$4:B$13)
B30:F30B30=SUM(BYROW($A$4:$A$13,LAMBDA(s,XLOOKUP(s,$A$17:$A$25,B$17:B$25,0,0)))*B$4:B$13*(B$4:B$13>5))
 
Upvote 0

Forum statistics

Threads
1,215,073
Messages
6,122,974
Members
449,095
Latest member
Mr Hughes

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