Weighted average price formula

gnaga

Well-known Member
Joined
Jul 9, 2002
Messages
748
Office Version
  1. 365
  2. 2016
  3. 2013
Platform
  1. Windows
Hi,

I need a formula to get an weighted average price of each item in a separate sheet. For Example please refer the below data. I have three different sheets where each item is marked with its qty and price. I have to make a new sheet where the weighted average price of each item is calculated. I need a formula for the Result Sheet4 to populate the Unique Item Code, Total Qty and its Weighted Average Price.

Sheet 1Sheet 2Sheet 3Result Sheet4
CodeQtyPriceCodeQtyPriceCodeQtyPriceCodeTot.QWt.Av.P
A10205.5H10023.0B74580.0A502108.16
A20102.0B20032.0B21600.0B320201.59
B25103.5D15045.0H35235.0C23851.20
C23851.2E20056.0W28125.0D17179.42
D21325.3A30058.0X26120.0E23156.94
E2056.3A12596.0U27105.0F10296.31
E1175.4F10087.0U29110.0G141145.52
F2562.0R20081.0A24100.0H13577.96
G5750.0R12021.0A23800.0L52542.46
G7823.0L22524.0G15600.0R32058.50
G2559.0L30056.3G18250.0U56107.59
W28125.00
X26120.00
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Book1
ABCDEFGHIJKLMNOPQR
1Sheet 1Sheet 2Sheet 3Formula
2CodeQtyPriceCodeQtyPriceCodeQtyPriceCodeTot.QWt.Av.P
3A10205.5H10023B74580A502108.16 502.00 108.16
4A20102B20032B21600B320201.59 320.00 201.59
5B25103.5D15045H35235C23851.2 23.00 851.20
6C23851.2E20056W28125D17179.42 171.00 79.42
7D21325.3A30058X26120E23156.94 231.00 56.95
8E2056.3A12596U27105F10296.31 102.00 96.31
9E1175.4F10087U29110G141145.52 141.00 145.52
10F2562R20081A24100H13577.96 135.00 77.96
11G5750R12021A23800L52542.46 525.00 42.46
12G7823L22524G15600R32058.5 320.00 58.50
13G2559L30056.3G18250U56107.59 56.00 107.59
14W28125 28.00 125.00
15X26120 26.00 120.00
16
Sheet2
Cell Formulas
RangeFormula
P3P3=SUM(IF(CHOOSE({1,2,3},$A$3:$A$13,$E$3:$E$13,$I$3:$I$13)=$M3,CHOOSE({1,2,3},B$3:B$13,F$3:F$13,J$3:J$13)))
Q3:Q15Q3=SUM(IF(CHOOSE({1,2,3},$A$3:$A$13,$E$3:$E$13,$I$3:$I$13)=$M3,CHOOSE({1,2,3},$C$3:$C$13*$B$3:$B$13,$G$3:$G$13*$F$3:$F$13,$K$3:$K$13*J$3:J$13)))/SUM(IF(CHOOSE({1,2,3},$A$3:$A$13,$E$3:$E$13,$I$3:$I$13)=$M3,CHOOSE({1,2,3},B$3:B$13,F$3:F$13,J$3:J$13)))
P4:P15P4=SUM(IF(CHOOSE({1,2,3},$A$3:$A$13,$E$3:$E$13,$I$3:$I$13)=M4,CHOOSE({1,2,3},$B$3:$B$13,$F$3:$F$13,$J$3:$J$13)))
 
Upvote 0
I just complicated things using choose out of curosity. Any using sumifs will be much easier.
 
Upvote 0
Book1
ABCDEFGHIJKLMNOPQR
1Sheet 1Sheet 2Sheet 3Formula
2CodeQtyPriceCodeQtyPriceCodeQtyPriceCodeTot.QWt.Av.P
3A10205.5H10023B74580A502108.16 502.00 108.16
4A20102B20032B21600B320201.59 320.00 201.59
5B25103.5D15045H35235C23851.2 23.00 851.20
6C23851.2E20056W28125D17179.42 171.00 79.42
7D21325.3A30058X26120E23156.94 231.00 56.95
8E2056.3A12596U27105F10296.31 102.00 96.31
9E1175.4F10087U29110G141145.52 141.00 145.52
10F2562R20081A24100H13577.96 135.00 77.96
11G5750R12021A23800L52542.46 525.00 42.46
12G7823L22524G15600R32058.5 320.00 58.50
13G2559L30056.3G18250U56107.59 56.00 107.59
14W28125 28.00 125.00
15X26120 26.00 120.00
16
Sheet2
Cell Formulas
RangeFormula
P3P3=SUM(IF(CHOOSE({1,2,3},$A$3:$A$13,$E$3:$E$13,$I$3:$I$13)=$M3,CHOOSE({1,2,3},B$3:B$13,F$3:F$13,J$3:J$13)))
Q3:Q15Q3=SUM(IF(CHOOSE({1,2,3},$A$3:$A$13,$E$3:$E$13,$I$3:$I$13)=$M3,CHOOSE({1,2,3},$C$3:$C$13*$B$3:$B$13,$G$3:$G$13*$F$3:$F$13,$K$3:$K$13*J$3:J$13)))/SUM(IF(CHOOSE({1,2,3},$A$3:$A$13,$E$3:$E$13,$I$3:$I$13)=$M3,CHOOSE({1,2,3},B$3:B$13,F$3:F$13,J$3:J$13)))
P4:P15P4=SUM(IF(CHOOSE({1,2,3},$A$3:$A$13,$E$3:$E$13,$I$3:$I$13)=M4,CHOOSE({1,2,3},$B$3:$B$13,$F$3:$F$13,$J$3:$J$13)))

Thanks CA_Punit,

It does what I need for Total Quantity and Weighted Average Price. Could you please explain what for the P4 Formula? Also I need to pick the item code from the three sheets to populate COLUMN "M" in. Could you please help me?
 
Upvote 0
Ignore the P4 formula. I suppose i forgot to edit it.

Consolidating Item code : It can be consolidated using Pivot table. Please copy in one sheet and use pivot to consolidate. Meanwhile i am trying to find out a formula solution.
 
Upvote 0
Sure I will try your suggestion and let you know. Thanks for your effort and time.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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