Skip to content

How to calculate cost of goods sold, line by line

Cost of goods sold is opening inventory plus purchases, less returns and discounts, plus carriage inwards, less closing inventory. In short: the stock you had, plus the stock you bought, minus the stock you still hold.

Updated 25 August 2026 · 6 min read

Cost of goods sold is six figures in a fixed order, and none of the arithmetic is harder than addition. Almost every wrong answer comes from a sign or an ordering mistake rather than from the sums — which is why the statement is written as a statement, with each line ruled off, instead of as one long formula.

What is cost of goods sold?

It is what the goods you actually sold cost you to obtain — not what you spent during the period, and not what you are still holding. A shop that buys £50,000 of stock in a year and sells three quarters of it has a cost of goods sold of roughly £37,500, not £50,000. The rest is still an asset sitting on the shelf.

Cost of goods sold is direct cost only. Rent, wages, software and marketing are not in it, which is why what it produces is gross profit rather than the profit you actually keep.

What is the formula for cost of goods sold?

One line, six terms. Every abbreviation below is the one used in the statement itself, so the formula and the printed accounts read the same way:

The working

NP    = P − PR − PD                          net purchases
COGAS = OI + NP + DE                         goods available for sale
COGS  = COGAS − CI                           cost of goods sold

COGS  = OI + P − PR − PD + DE − CI           all of it, in one line

OI is opening inventory, P purchases, PR purchase returns, PD purchase discounts, DE direct expenses such as carriage inwards, and CI closing inventory. The one-line version is the same statement with the subtotals removed — useful for checking an answer, useless for finding a mistake.

How do you write the statement?

Nine lines, in this order. The two subtotals are what make it checkable: if net purchases or goods available for sale looks wrong, you know which half of the statement to go back to.

The cost of goods sold statement, in the order it is written
LineCodeAmount
Opening inventoryOI12,400.00
Add: PurchasesP48,750.00
Less: Purchase returnsPR(1,280.00)
Less: Purchase discountsPD(940.00)
Net purchasesNP46,530.00
Add: Direct expenses / carriage inwardsDE2,150.00
Cost of goods available for saleCOGAS61,080.00
Less: Closing inventoryCI(14,600.00)
Cost of goods soldCOGS46,480.00
  1. Take last period’s closing stock as this period’s opening stockThey are the same figure looked at from two sides. If the two do not match, one of the two periods has the wrong stocktake and the error will run through both sets of accounts.
  2. Add purchases, then take off returns and discountsEverything bought for resale at invoice value, less goods sent back to the supplier and any settlement or trade discount received. What is left is net purchases.
  3. Add carriage inwards and any other direct expenseFreight, import duty and insurance in transit are part of what the goods cost you. Add them to reach the cost of goods available for sale.
  4. Subtract the closing stockWhatever is still on the shelf at the end has not been sold, so its cost has not been incurred. Take it back out, and what remains is the cost of goods sold.

A worked example

A small shop with £12,400 of stock at the start of the year buys £48,750, sends £1,280 back, is given £940 in discounts, pays £2,150 in carriage in, and counts £14,600 of stock at the year end:

The working

Net purchases:             £48,750.00 − £1,280.00 − £940.00 = £46,530.00
Goods available for sale:  £12,400.00 + £46,530.00 + £2,150.00 = £61,080.00
Cost of goods sold:        £61,080.00 − £14,600.00 = £46,480.00

Note what the closing stock does. The shop spent £48,750 on purchases, but its cost of goods sold is £46,480 — lower, because it ended the year holding more stock than it started with. Spending and cost of goods sold are different numbers and only meet when opening and closing stock are equal.

How does gross profit follow from it?

Sales less cost of goods sold is gross profit, and gross profit as a share of sales is the gross profit margin. The division is by sales, never by cost:

The working

Gross profit:         £79,500.00 − £46,480.00 = £33,020.00
Gross profit margin:  £33,020.00 ÷ £79,500.00 = 41.5%   (share of sales)
Markup:               £33,020.00 ÷ £46,480.00 = 71.0%   (share of cost)

Same £33,020 either way. Quoting the 71% as though it were a margin is the period-level version of the mistake the margin calculator exists to stop, and it is just as expensive here.

Where does the statement usually go wrong?

  • Closing inventory added instead of subtracted. It is the most common error in the whole statement and it moves the answer by twice the value of the stock — enough to turn a good year into a loss on paper.
  • Gross purchases used in place of net purchases. Returns and discounts are forgotten, cost is overstated, profit is understated, and every figure still looks plausible.
  • Carriage outwards included. What you pay to get stock in belongs here; what you pay to send goods out to a customer is a selling expense and sits below the gross profit line.
  • Figures from different periods. A year of purchases against a quarter of sales produces a margin that cannot happen, and the impossible-looking number is usually the only clue.
  • VAT left in. If you can reclaim it, it was never a cost to you. Enter everything net.

Does the stock valuation method change the answer?

Yes, and none of the arithmetic above changes with it. FIFO, weighted average and net realisable value can each put a different value on the same physical shelf, and that closing figure feeds straight into the last line of the statement. In a period of rising prices FIFO leaves a higher closing stock, so a lower cost of goods sold and a higher reported profit than weighted average would give — from identical purchases and identical sales. Pick one method and stay with it; switching is a change of accounting policy, not a tidy-up.

What is my opening inventory in my first year of trading?

Zero, unless you bought stock before the business started trading, in which case the opening figure is what that stock cost you. Everything else you buy in the first year goes through purchases as normal, so the statement works exactly as it does in any later year — it simply starts from nothing.

Does cost of goods sold include labour?

Not for a shop or a wholesaler, where it is the cost of buying the goods and getting them in. A manufacturer is different: its cost of goods sold folds in direct labour and factory overheads as well as raw materials, and is built from a cost of goods manufactured statement that sits before this one. The layout here covers the buy-and-resell case.

Can cost of goods sold be negative?

No. A negative result means the figures are wrong, usually because closing inventory has been entered as more than everything available to sell, or because the stocktake was valued at selling price rather than at cost. It can also mean a purchase invoice is missing from the period. Any of the three is worth finding before the accounts go anywhere.

How often should I calculate it?

At least once a year, because you need it for the accounts, and monthly if you carry meaningful stock. The limiting factor is the stocktake: cost of goods sold needs an opening and a closing inventory figure, and without a real count those are estimates. Many businesses count fully once a year and use a rolling stock system for the months in between.

What is the difference between cost of goods sold and expenses?

Cost of goods sold is what the sold goods cost you, and it varies directly with how much you sell. Expenses are what it costs to run the business whether you sell anything or not — rent, wages, insurance, software. Sales less cost of goods sold is gross profit; gross profit less expenses is net profit, and only the second one tells you whether the business works.

Check this before you rely on it. A free guide to everyday arithmetic — not tax, accounting, financial, legal or medical advice. The working is shown above so you can verify it against your own figures. See our terms of use.