Sumproduct In Excel

varunwalla

New Member
Joined
Aug 13, 2020
Messages
32
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
  2. Mobile
  3. Web
Hello everyone,

I need to calculate the average price of a product let say Orange.

  1. First 30 Qty of Orange is bought at 8.85 so the value becomes 265.50
  2. Next 5 Qty of Orange is bought at 8.75 so the value becomes 43.75
  3. Total cost of 35 Qty is 309.25
  4. Now taking the average value of 35 is 8.84 ( rounding to 2 digit ) i.e 309.25 divide by 35

At the moment i am using this procedure to calculate the average value


Code:
=SUMPRODUCT(E3+E4)/(C3+C4)*(B3="Orange")

is there any techniques to simplify this for each product i am manuly entering the reference cells for apple i am entering it as

Code:
=SUMPRODUCT(E2+E5)/(C2+C5)*(B5="Apple")

is there any formula to simplify these steps

Sumproduct.xlsx
ABCDEFGHI
1S.NoProduct NameQuantityPriceTotal PriceAverage Price CostTotal Investment Cost
21Apple5198.00990.00Orange8.84Orange
32Orange308.85265.50Apple204.00Apple
43Orange58.7543.75
54Apple5210.001050.00
Sheet 1
Cell Formulas
RangeFormula
G2G2=SUMPRODUCT(E3+E4)/(C3+C4)*(B3="Orange")
G3G3=SUMPRODUCT(E2+E5)/(C2+C5)*(B5="Apple")
A3:A5A3=(A2+1)
E2:E5E2=(C2*D2)


Any help would be much appreciated
 

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,)
One more thing tired out is to try out If function i.e c3=sale then in h2 the calculation should be ignored too much if function googled out like if, countif, nested if what to try out i.e the value in h2 should be display as 8.84


Sumproduct.xlsx
ABCDEFGHIJ
1S.NoProduct NameTypeQuantityPriceTotal PriceAverage Price CostTotal Investment Cost
21ApplePurchase5198.00990.00Orange9.17Orange641.75
32OrangePurchase308.85265.50Apple204Apple2040.00
43OrangePurchase58.7543.75
54ApplePurchase5210.001050.00
65OrangeSale359.50332.50
Sheet 1
Cell Formulas
RangeFormula
H2:H3H2=ROUND(SUMIF($B:$B,$G2,$F:$F)/SUMIF($B:$B,$G2,$D:$D),2)
J2:J3J2=SUMIF($B:$B,$I2,$F:$F)
A3:A6A3=(A2+1)
F2:F6F2=(D2*E2)
 
Upvote 0
You need SUMIFS for multiple criteria:

=ROUND(SUMIFS($F:$F,$B:$B,$G2,$C:$C,"<>Sale")/SUMIFS($D:$D,$B:$B,$G2,$C:$C,"<>Sale"),2)

Note that with SUMIFS, the range to sum goes first, not last.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,728
Members
448,987
Latest member
marion_davis

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