The cost of goods sold formula is opening inventory value, plus purchases made during the period, minus closing inventory value. That single calculation tells you the true direct cost of everything you actually sold — not what you spent on suppliers, and not what's still sitting on the shelf. Get it wrong, and gross profit is wrong too, even if every other number in your books is perfect.
Cost of goods sold (COGS) is calculated as opening inventory value plus purchases made during the period, minus closing inventory value. It represents the direct cost of the products a business actually sold, and subtracting it from revenue gives gross profit — the clearest measure of core buying-and-selling profitability.
This lesson looks at COGS through inventory and costing: how the method you choose moves cost between COGS and closing inventory. For the step-by-step calculation, including from an income statement, from a trial balance and for retail, see how to calculate cost of goods sold.
Key takeaways
- COGS = Opening inventory + Purchases − Closing inventory. It measures what you sold, not what you bought or what you still hold.
- COGS includes only direct costs — the goods themselves and directly attributable costs like inbound freight — not rent, marketing, or admin salaries.
- Revenue minus COGS is gross profit, the number that shows whether your core buying-and-selling activity is profitable before overhead is even considered.
- COGS is only as accurate as your inventory records. A stock count that's drifted from reality quietly produces a wrong COGS, even with perfect purchase records.
- Your costing method (FIFO or average cost) decides which purchase prices land in COGS versus stay in closing inventory when prices move.
What cost of goods sold actually measures
COGS is the direct cost of the products a business sold during a specific period — a month, a quarter, a year. It is not the same thing as how much you spent buying stock during that period, and it's not the same as your total expenses.
The reason those three numbers differ is timing. You might buy $10,000 of stock in March but sell only $7,000 worth of it — the rest is still sitting in inventory at month-end, and it isn't part of March's COGS yet. The formula exists precisely to separate what you spent from what you sold.
The cost of goods sold formula
COGS = Opening inventory + Purchases − Closing inventory
The cost of goods sold formula
Read it as a flow. Opening inventory is what you had on hand at the start of the period. Add everything purchased during the period, and you get the total value of goods available for sale. Subtract whatever is still unsold at the end — closing inventory — and what's left is the cost of what actually left the building as a sale.
What's included in COGS, and what isn't
COGS is limited to direct costs — the ones tied specifically to the products sold:
- The purchase price (for a retailer or wholesaler) or manufacturing cost (for a producer) of the goods.
- Directly attributable costs like inbound freight to get the goods into stock.
It excludes indirect operating costs, which are recorded separately as operating expenses further down the income statement: rent, marketing, office salaries, insurance, and similar overhead. A business selling $1,000 of product that cost $600 to buy or make has a $600 COGS regardless of how much it spent that month on advertising or the shop lease.
A worked example
Cedar Grove Wholesale sells reusable water bottles to smaller retailers. Here's January.
| Component | Amount |
|---|---|
| Opening inventory (1 January) | $18,400 |
| Purchases during January | $32,600 |
| = Goods available for sale | $51,000 |
| Closing inventory (31 January) | $21,000 |
| = Cost of goods sold | $30,000 |
COGS = $18,400 + $32,600 − $21,000 = $30,000.
If January's revenue was $52,000, gross profit is $52,000 − $30,000 = $22,000, a gross margin of $22,000 ÷ $52,000 = 42.3%. Every dollar of that COGS figure depends on the $18,400 and $21,000 inventory values being accurate — which is exactly why a physical stock count matters so much to a number that looks, on the surface, like a purchasing calculation.
If closing inventory is overstated — say, because stock that was actually stolen or damaged is still counted as on-hand — COGS comes out understated, and gross profit looks better than it really is. The formula has no way to catch that on its own; only an accurate count does. It's one of the common inventory and costing mistakes that quietly distorts a business's real profitability.
How your costing method changes the COGS number
The formula tells you what to calculate, but not which specific purchase price to use when the same product was bought at different prices during the period. That's decided by your costing method — typically FIFO (first-in, first-out) or average cost. FIFO vs average costing, with a worked example shows exactly how the same set of purchases and sales produces a different COGS figure depending on which method you use. Neither method changes how much cash the business actually made — only how that same total is split between COGS and the value left in inventory.
A quick example. A product starts the month with 100 units at $10 each ($1,000). You then buy 100 more units at $12 each ($1,200) and sell 120 units. Goods available for sale cost $2,200 in total. Costed two ways:
| Method | COGS (120 units sold) | Closing inventory (80 units) |
|---|---|---|
| FIFO: 100 × $10 + 20 × $12 | $1,240 | $960 (80 × $12) |
| Average cost: $2,200 ÷ 200 units = $11 per unit | $1,320 (120 × $11) | $880 (80 × $11) |
Both methods account for the same $2,200 of cost; they only split it differently between COGS and closing inventory. Because prices rose, FIFO charges the older, cheaper units to COGS first, so COGS is $80 lower and gross profit $80 higher than under average cost. If prices had fallen the effect would reverse, and if every unit cost the same the two methods would agree. (The example assumes both purchases arrive before the sale.)
For a manufactured product rather than a bought-and-resold one, the "purchase price" in the formula is replaced by the manufacturing cost per unit, which a bill of materials is built to calculate properly — materials, labor, and overhead, not just the raw ingredients.
Why COGS matters more than it looks like it should
COGS determines gross profit, and gross profit is the first real signal of whether the core of the business — buying or making something, then selling it for more — actually works, before rent, wages, and every other overhead cost even enters the picture. Two businesses with identical revenue can have very different gross profit if one has sloppy inventory records inflating or understating COGS.
It's also a number lenders, investors, and your own income statement rely on directly — everything from pricing decisions to gross margin analysis starts from an accurate COGS figure. A "good" COGS percentage varies enormously by industry (retail often runs 50–65% of sales; food and beverage businesses often target closer to 28–35% for food cost specifically), so tracking your own number consistently, using the same terms defined in the inventory and costing glossary, matters more than chasing a generic benchmark.
Every Reyuko Invoice posts cost of goods sold automatically the moment you record a sale — debiting COGS and crediting Inventory alongside the revenue and tax entries, using whichever costing method (Average, FIFO, or LIFO) you've set on that product. You don't calculate COGS by hand at month-end from a separate spreadsheet: it's built into every sale as it happens.
The Income Statement report, under Reporting, is generated live from the ledger, so gross profit — revenue minus that same COGS — is already sitting there whenever you check it, rather than something you reconstruct at period-end. Because it's live, it reflects a stock opname adjustment the moment you post one, instead of waiting for a manual recalculation.
Product catalog, sales, inventory, and core reporting including the Income Statement are all in Reyuko's free edition — none of this depends on a paid plan.
Check yourself: calculate this month's COGS
A café supply shop starts the month with $9,200 of inventory, buys $14,300 more during the month, and counts $8,100 remaining at month-end. What's COGS?
Answer: $9,200 + $14,300 − $8,100 = $15,400.
Reyuko