Weighted average cost formula required

JackDanIce

Well-known Member
Joined
Feb 3, 2010
Messages
9,922
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a series of transactions and need to calculate the average cost which includes both buys and sells.

E.g.

Purchase 100 shares @£1/share
Purchase 50 shares @£1.50/share
Sell 25 shares @£2/share
Purchase 30 shares @£1.60/share

Weighted total cost after each transaction
£100 (100 * £1; implies £1/share cost)
£175 (50 more bought: 50 * £1.5 + 100 * £1 = £175 total cost, implies £1.17/share)
£145.83 (25 sold, therefore 125 remain. 125 * £1.17 = £145.83 total cost for the remaining 125)
£180.83 (30 more bought, 125 * £1.17 + 30 * £1.60 = £180.83, implies £1.25/share)

Could someone help suggest a formula for the weighted costs (£100, £175.50, £145.83 and £180.83 respectively) please? The transactions will always begin with a purchase.

Thank you in advance,
Jack
 
Last edited:
A​
B​
C​
D​
E​
1​
Qty
Unit Price
Own
Avg Cost
2​
0
$0.00
0
$0.00
3​
100​
$1.00​
100​
$1.00​
C3: =C2+A3
4​
50​
$1.50​
150​
$1.17​
D3: =IF(A3 < 0, D2, (C2*D2 + A3*B3)/C3)
5​
(25)​
$2.00​
125​
$1.17​
6​
30​
$1.60​
155​
$1.25​

I have no idea how to usefully interpret that number.
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
A​
B​
C​
D​
E​
1​
Qty
Unit Price
Own
Avg Cost
2​
0
$0.00
0
$0.00
3​
100​
$1.00​
100​
$1.00​
C3: =C2+A3
4​
50​
$1.50​
150​
$1.17​
D3: =IF(A3 < 0, D2, (C2*D2 + A3*B3)/C3)
5​
(25)​
$2.00​
125​
$1.17​
6​
30​
$1.60​
155​
$1.25​

I have no idea how to usefully interpret that number.

cost * own in your example is close to what I got (with some rounding differences):


Excel 2010
E
2$100.00
3$175.00
4$145.83
5$193.75
Sheet4
Cell Formulas
RangeFormula
E2=C2*D2


and your structure/formulas are more efficient
 
Last edited:
Upvote 0
Last edited:
Upvote 0
Hi shg, I'm working for a client that offers software for managing a particular kind of tax efficient investment in the UK.

Due to being able to defer or carry taxes when assets are sold, the client needs to track the average cost of the remaining holdings (buys only).

The link above may help explain better but understand you reaction of it not being a useful number!
 
Upvote 0
For now.. I'm still testing against different transactions, though suggested formula is definitely closer than one I had.

I'll revert if any updates, thank you for asking though.
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

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