Eren Labs JOURNAL TR
Store Operations

Weighted Average Cost: The Formula, a Worked Example and When to Use It

Weighted average cost values every unit in stock at the average price you paid for it. The formula, a moving average worked through deliveries and a sale, the periodic version, how it compares with FIFO and last cost, and the edge cases that trip shops up.

In this article9 sections

The weighted average cost method values every unit of a product at the average price you paid for all the units you hold. When a delivery arrives: new average cost = (units on hand × current average + units received × price paid) ÷ (units on hand + units received). Sales then leave at that average, so cost of goods sold and stock value both use it. This guide works the formula through a delivery, a sale and a second delivery, shows the periodic version accountants use, compares weighted average with FIFO and “last cost”, and covers the edge cases that trip shops up.

A quick note on the name: “weighted average cost of capital” (WACC) is a finance measure of what a company pays for its funding, and has nothing to do with stock. This page is about inventory.

The weighted average cost formula#

There are two versions, and they differ only in when you work out the average.

  • Moving (perpetual) weighted average: recalculate after every delivery.
    New average = (on-hand units × current average + received units × unit price) ÷ (on-hand units + received units)
  • Periodic weighted average: work out one average for the whole period.
    Average = cost of goods available for sale ÷ units available for sale, where goods available means opening stock plus everything bought in the period.

Shops whose stock system updates with every sale use the moving version. The periodic version suits a business that only values stock at year end; our guide to perpetual vs periodic inventory explains the difference between the two systems.

A worked example: moving weighted average cost#

Illustration: a running average cost that moves with each delivery and stays the same when stock is sold
A moving average changes only when stock arrives at a different price. Selling takes units out at the current average.

A shop sells a ceramic mug. Over a month:

EventUnitsUnit priceUnits on handStock valueAverage cost
Opening stock405.0040200.005.00
Delivery 1+605.50100530.005.30
Sale−30at 5.3070371.005.30
Delivery 2+506.00120671.005.59
  • After delivery 1: (40 × 5.00 + 60 × 5.50) ÷ 100 = 530.00 ÷ 100 = 5.30.
  • The sale of 30 mugs costs 30 × 5.30 = 159.00 in cost of goods sold. The average doesn’t change when you sell.
  • After delivery 2: (70 × 5.30 + 50 × 6.00) ÷ 120 = 671.00 ÷ 120 = 5.59 (5.5917, rounded).

Keep more decimals in the calculation than you show. Rounding the average to two places after every delivery adds small errors that build up over a year of deliveries.

The periodic weighted average, same month#

Goods available for sale: 40 × 5.00 + 60 × 5.50 + 50 × 6.00 = 830.00 for 150 units, an average of 5.53. Every unit sold in the month is costed at 5.53, so the 30 mugs cost 166.00 instead of 159.00, and closing stock of 120 mugs is valued at 664.00 instead of 671.00. Both versions are correct; they just spread the price rise differently. The periodic version can only be worked out once the period is over.

Weighted average cost in a spreadsheet#

One row per event, in date order, with these columns: units in or out in B (negative for sales), unit price in C (only for deliveries), units on hand in D, stock value in E and average cost in F. From row 3 on:

D3  =D2+B3
E3  =IF(B3>0, E2+B3*C3, E2+B3*F2)
F3  =IF(D3>0, E3/D3, F2)

A delivery adds its cost to the stock value; a sale takes out units at the previous average. The average is the stock value divided by units on hand, and if stock drops to zero it carries the last average forward. Put the opening stock in row 2 by hand: units in D2, value in E2 and average in F2. On the mug example these formulas give 5.30 after the first delivery and 5.5917 after the second.

Weighted average vs FIFO vs last cost#

MethodCost of the 30 mugs soldHow it worksGood for
Moving weighted average159.00Each sale at the current averageInterchangeable goods, a system that updates per delivery
FIFO150.00Oldest units leave first (the opening 40 at 5.00)Perishables, goods with batches or expiry dates
Last cost165.00Everything valued at the most recent price paid at the time (5.50)A quick estimate; not a recognised valuation method

When prices rise, FIFO gives a lower cost of goods sold and a higher closing stock value, weighted average sits in between, and last cost overstates both the cost of sales and the stock. Under IAS 2, the international standard for inventories, FIFO and weighted average are the two permitted cost formulas for ordinary interchangeable goods. Whichever you choose, use it consistently; your accountant will want the same method every year.

For a small shop, the practical argument for weighted average is that it needs no batch records. FIFO means knowing which delivery each unit came from, which is easy for a pharmacy tracking expiry dates and hard for a shop with one bin of identical mugs. Weighted average only needs the quantity and price of each delivery, which you already have on the supplier’s invoice. It also smooths out one-off price spikes, so a single expensive delivery doesn’t swing the margin of every sale that follows it.

Edge cases that break weighted average cost#

  • Stock at zero. With nothing on hand, the next delivery’s price becomes the average outright. That is correct, but it means a single expensive emergency order resets the average.
  • Negative stock. If you sold units you hadn’t booked in, the on-hand figure is below zero and the formula gives nonsense, sometimes a negative or huge average. Book deliveries in before selling them, or treat a negative balance as zero for the calculation.
  • Extra costs. Shipping and import duty paid to bring the goods in belong in the unit price (landed cost). Leaving them out makes every product look more profitable than it is.
  • Returns to the supplier and reversed receipts. Taking units back out at a price different from the current average leaves a small distortion. Many systems don’t recalculate the average when a receipt is undone, so check the cost by hand after a large reversal.
  • Invoice price changes. If the supplier’s invoice differs from the purchase order price, update the received cost to the invoiced price; see our guide to purchase order vs invoice for the matching step.
  • Stock count corrections. Units found or lost in a count are valued at the current average; they change the quantity, not the average.

Why the cost number matters#

Every margin figure starts from cost. If a product’s cost field still holds the price from two years ago, its margin, the shop’s gross profit and the value of the stock are all wrong by the same drift. The free GMROI calculator shows how much gross margin each unit of stock investment returns, which only means something when cost is current. Our guides to cost of goods in WooCommerce and to inventory valuation show where cost lives in WooCommerce and how it turns into a stock value.

Weighted average cost in WooCommerce with PurchaseDesk#

WooCommerce can store a cost per product, but nothing in WooCommerce updates it when stock arrives. PurchaseDesk, our purchasing plugin, does. In the free version on WordPress.org, receiving a delivery against a purchase order writes the unit cost you received at as the product’s cost, in the fields WooCommerce and the common cost-of-goods plugins read, including WooCommerce’s own Cost of Goods Sold field when that is enabled. A setting decides whether receiving updates cost at all.

PurchaseDesk receipt history: each receipt with quantity, unit cost and stock before and after, with a Reverse action
PurchaseDesk (free): every receipt keeps its quantity, unit cost and stock before and after, the inputs an average cost is built from.

That free behaviour is last cost: the newest price replaces the old one. Every receipt is logged with its quantity, unit cost and stock before and after, so the history to work out an average is there, and reversing a receipt puts stock back without recalculating the cost. PurchaseDesk Pro, from $79 a year, switches the calculation to weighted-average costing as stock arrives, using the formula above, and adds purchase reports and a stock value at cost on its dashboard.

Weighted average cost: frequently asked questions#


What is the weighted average cost formula?

For a moving average, new average cost equals units on hand times the current average, plus units received times their price, divided by total units after the delivery. For a periodic average, divide the cost of all goods available in the period by the units available.


Is weighted average cost the same as WACC?

No. WACC, the weighted average cost of capital, measures what a company pays for its funding. Weighted average cost in inventory is the average price paid per unit of stock.


Does selling stock change the weighted average cost?

No. Sales take units out at the current average, so the average stays the same. Only receiving stock at a different price changes it, together with returns to the supplier at another price.


Is weighted average better than FIFO?

Neither is better in general. FIFO suits perishable or batch-tracked goods; weighted average suits interchangeable goods bought at changing prices. Pick one, use it consistently, and agree it with your accountant.


Should shipping be included in weighted average cost?

Yes. Inbound shipping, duty and other costs of bringing goods into stock are part of their cost. Spread them over the units received before working out the average.


More in Store Operations

Keep exploring

All articles
Before you go Let PurchaseDesk do this in WooCommerce

Keep suppliers, purchase orders and goods received next to your WooCommerce stock. Record what arrived, what it cost and what is still on order.

Explore PurchaseDesk Get the free version

Free version on WordPress.org · Pro from $79/year