Cost of goods sold formula, with real stock
The cost of goods sold formula, worked with real stock: opening inventory plus purchases less closing inventory.
Cost of goods sold (COGS) is what you paid for the stock you sold in a period. It leaves out rent, wages and marketing. Sales minus COGS is your gross profit.
The cost of goods sold formula
COGS = opening stock value + purchases − closing stock value
Opening stock is what your stock was worth at the start of the period. Purchases are what you bought during it, including freight and duty. Closing stock is what was left at the end.
How to calculate cost of goods sold
A shop starts the month with no insulated bottles. It receives 100 at $10 each, then 100 at $12 each. It sells 150.
Purchases = (100 × 10) + (100 × 12) = $2,200
To finish the sum you need the value of the 50 bottles left. That depends on which bottles you count as sold, and there are two common answers.
First in, first out (FIFO)
FIFO treats the oldest stock as sold first. The 150 sold are the 100 bought at $10 and 50 of those bought at $12.
COGS = (100 × 10) + (50 × 12) = $1,600
Closing stock = 50 × 12 = $600
Moving average
Moving average gives every unit on the shelf the same cost. After both deliveries the shop has 200 bottles that cost $2,200, so each is worth $11.
COGS = 150 × 11 = $1,650
Closing stock = 50 × 11 = $550
Both answers are correct. Both add up to the $2,200 spent. FIFO puts more of it in closing stock when prices are rising, so this month’s profit looks higher.
| FIFO | Moving average | |
|---|---|---|
| Cost of goods sold | $1,600 | $1,650 |
| Closing stock | $600 | $550 |
| Gross profit on $4,500 of sales | $2,900 | $2,850 |
What belongs in the cost
- The price you paid the supplier.
- Freight, duty and import fees to get the goods to you. This is the landed cost.
- Materials used to make or assemble the product.
Leave out postage to the customer, marketplace fees, packaging you add at dispatch and staff time. Those are running costs, not the cost of the goods.
Mistakes that distort COGS
- Stock with no cost. A unit received at $0 sells at 100% margin on paper.
- A late freight bill added to the wrong month.
- Stock written off or lost and never recorded. It stays in closing stock and COGS reads too low until the next count.
- Changing method part way through a year. Pick one and keep it, or your accountant has to restate the earlier months.
Cost of goods sold and operating expenses
Cost of goods sold is the cost of the products themselves. Operating expenses are the cost of running the business. Rent, wages for office staff, marketing and software are operating expenses. They come off after gross profit, not before.
Cost of goods sold with a perpetual system
The formula above is for a business that counts stock at the end of a period. A system that records every sale works it out as it goes: each time a unit ships, its cost is added to cost of goods sold. The total is the same. You see it every day in place of once a year. See perpetual vs periodic inventory.
Where the costing method comes in
When you buy the same product at different prices, the cost of the unit you sold depends on your method. See FIFO vs LIFO vs weighted average.
In ShipBerry
ShipBerry records a cost on every receipt and carries it into each sale. Reports show inventory value, cost of goods sold and gross profit per order and per product. Moving average is on every plan. Other methods and landed costs are on Inventory Plus.
Related
Last updated 30 November 2026 · More on costing