How to Calculate Cost of Goods Sold (COGS): The Formula, Worked

👈 Want to see COGS post itself on every sale? Open an instant live demo — no signup needed →

Quick answer: How do you calculate cost of goods sold?

Cost of goods sold = beginning inventory + purchases during the period − ending inventory. Start the year with $84,000 of stock, buy $310,000 more including freight-in, count $102,000 left on the shelf, and your COGS is $292,000. Only direct costs belong in it — the goods themselves, freight-in, and the labor that makes or delivers what you sold. Rent, marketing, and office salaries are operating expenses, not COGS. Service businesses have the same number under the name cost of services. BizBooks Pro treats Cost of Goods Sold as its own account type, so gross profit appears as a real subtotal on your profit and loss statement, and perpetual inventory posts the COGS entry automatically the moment a product sells.

Two businesses each did $520,000 in sales last year, and one of them is in trouble. The difference doesn't show up in the revenue line, the bank balance, or the tax return — it shows up in cost of goods sold, and in the gross profit that survives it. COGS is the single most important number on a product business's income statement after revenue itself, and it's also the one most often calculated wrong, usually by accident and usually in the same direction.

This guide covers how to calculate cost of goods sold from first principles: the formula, which costs actually belong inside it, what service businesses do instead, the journal entries under both inventory methods, and the five errors that quietly distort the number every year.

What Cost of Goods Sold Actually Measures

Cost of goods sold is what the things you sold cost you. Not what you bought this month — what you sold this month. That distinction is the whole game.

Buy 500 chairs in March and sell 100 of them, and only the cost of those 100 is an expense. The other 400 are still an asset sitting on your balance sheet as inventory, waiting for the month they finally sell. This is the matching principle at work: the cost of an item belongs in the same period as the revenue it produced, not the period you happened to pay the supplier.

On your profit and loss statement, COGS gets its own position directly beneath revenue, and the subtraction creates the gross profit subtotal:

LineAmountWhat it tells you
Revenue$520,000What customers paid you
Cost of Goods Sold($292,000)What those sales cost you directly
Gross Profit$228,000What's left to run the business (43.8%)
Operating Expenses($186,000)Rent, admin, marketing, insurance
Net Profit$42,000What you actually kept

Without a clean COGS figure, that gross profit line doesn't exist — and you lose the ability to tell a pricing problem from an overhead problem. Both look identical at the net profit line, and they have completely different fixes.

The Cost of Goods Sold Formula

What is the formula for cost of goods sold?

Three numbers, one subtraction:

COGS = Beginning Inventory + Purchases − Ending Inventory

The reasoning underneath it is almost aggressively simple. Everything you had available to sell during the period is your opening stock plus everything you bought. Whatever is still sitting there at the end, you didn't sell. Subtract it, and what remains is what went out the door.

Here it is on Northgate Bicycle Co., a shop with a full year behind it:

ComponentAmountWhere it comes from
Beginning inventory (Jan 1)$84,000Last year's ending inventory, unchanged
Purchases$298,000Supplier invoices for stock
Freight-in on those purchases$12,000Getting the bikes to the shop
= Goods available for sale$394,000Everything you could have sold
− Ending inventory (Dec 31)($102,000)Physical count, valued at cost
= Cost of goods sold$292,000What you sold, at your cost

Manufacturers swap one term. If you make what you sell rather than buying it finished, replace “purchases” with cost of goods manufactured — raw materials used, direct labor, and factory overhead, tracked across raw materials, work in process, and finished goods. The formula's shape never changes; only the middle number gets more work behind it.

What Belongs in COGS — and What Doesn't

What is included in cost of goods sold?

COGS holds direct costs: the ones that exist because you produced or acquired the specific things you sold. Everything else is an operating expense. The test that settles almost every case:

If you sold nothing at all next month, would this cost still arrive? If yes, it's an operating expense. If it disappears along with the sales, it's a direct cost.

Rent arrives whether you sell one unit or a thousand — operating expense. The wholesale cost of the bike doesn't exist unless you bought a bike to sell — COGS.

CostGoes inWhy
Wholesale cost of goods purchasedCOGSThe product itself
Raw materials and componentsCOGSBecomes part of the product
Freight-in and import dutyCOGSCost of getting inventory in hand
Wages of staff who build or deliver the workCOGSDirect labor
Subcontractors on billable jobsCOGSDirect cost of that job
Factory rent, production equipment depreciationCOGSManufacturing overhead
Freight-out (shipping to the customer)Operating expenseSelling cost, not product cost
Sales commissionsOperating expenseCost of selling, not of making
Office salaries, admin, bookkeepingOperating expenseArrives regardless of sales
Marketing and advertisingOperating expenseCreates demand, not product
Office rent, insurance, software subscriptionsOperating expenseFixed overhead

Is shipping included in cost of goods sold?

Only in one direction. Freight-in — what you pay to get inventory to your door — is part of what that inventory cost, so it sits in inventory value and moves into COGS when the item sells. Freight-out — what you pay to ship a customer's order — is a selling expense, and belongs below the gross profit line.

The reason this matters beyond tidiness: freight-out grows with order volume, so parking it in COGS makes your gross margin look worse in busy months and better in slow ones, which is exactly backwards. Split them, even when the same courier bills both on one invoice. Our guide to categorizing business expenses covers the wider version of this problem.

COGS for Service Businesses

Do service businesses have cost of goods sold?

Yes — usually labelled cost of services or cost of revenue, and skipping it is one of the most expensive omissions in small business bookkeeping. Plenty of agencies, contractors, and consultancies dump every payroll dollar into one Wages expense account below the gross profit line, which leaves them with no gross margin at all and no way to tell a profitable client from a loss-making one.

Take Ridgeline Design, a six-person studio billing $40,000 in a month:

CostAmountTreatment
Wages of the three designers on billable work$16,500Cost of services
Employer payroll taxes on those wages$1,400Cost of services
Freelance copywriter for one client project$3,200Cost of services
Stock photography licensed for a specific job$400Cost of services
Office manager's salary$4,200Operating expense
Studio rent and utilities$2,900Operating expense
Design software subscriptions (whole team, always)$650Operating expense

Cost of services totals $21,500, so gross profit is $18,500 — a 46% gross margin. That single percentage is the health check on your rates and your utilization, and it's invisible if all seven lines sit in one bucket. Push it further with job costing and you get the same margin per project, which is where you discover that your biggest client is also your least profitable one.

Owner's time is the honest exception. If you're a sole proprietor taking draws rather than a salary, there's no wage expense to classify — your labor never hits the books at all, and your gross margin is flattered accordingly. Worth remembering before you price a job off that margin. See owner's draw vs. salary for why the books treat the two so differently.

Where the Number Comes From: Periodic vs. Perpetual

The formula tells you what COGS is. How it reaches your books depends on which inventory method you run.

Periodic: count first, then calculate

Purchases go to a Purchases account all period. Nothing touches COGS until you physically count what's left, and then one adjustment produces the whole year's figure. Cheap to operate, and blind between counts — you don't know your gross margin in March until December's count is done.

Using Northgate's numbers, the year-end entry runs in two steps as part of your closing entries:

AccountDebitCredit
Cost of Goods Sold$310,000
Purchases (incl. freight-in)$310,000
Then adjust inventory from $84,000 to the counted $102,000:
Inventory$18,000
Cost of Goods Sold$18,000

Net COGS: $310,000 − $18,000 = $292,000. Same answer the formula gave.

Perpetual: every sale posts its own cost

Each sale fires two entries — one for the revenue, one for the cost — so inventory and COGS are correct continuously. Sell a bike that cost you $410 for $780:

AccountDebitCredit
Accounts Receivable (or Cash)$780
Sales Revenue$780
And simultaneously, the cost side:
Cost of Goods Sold$410
Inventory$410

Notice the second entry never touches cash — it moves $410 from an asset to an expense, which is all “recognizing COGS” has ever meant in double-entry bookkeeping. You still count stock at least annually, but now the count verifies the books instead of creating them, and the gap between counted and recorded value is your shrinkage — a number periodic inventory hides inside COGS forever.

Your Costing Method Changes the Answer

One detail trips people up: if you bought the same product at different prices during the year, the formula needs to know which units you sold. Buy 100 widgets at $10 in March and 100 at $14 in September, sell 120, and COGS is $1,280 under FIFO or $1,480 under LIFO — from identical transactions.

The three permitted approaches are FIFO (oldest cost first), LIFO (newest cost first, and not permitted under IFRS), and weighted average. Pick one, apply it consistently, and document it. Our guide to inventory costing methods works all three through the same purchase history and shows what each does to gross profit and to your tax bill.

Five Ways COGS Goes Wrong

  1. Posting inventory purchases straight to COGS. The most common error by a distance. Buying stock isn't an expense — it's converting cash into another asset. Expense it on arrival and every month you stock up looks unprofitable while every month you sell down looks brilliant.
  2. Ending inventory valued at retail. The count must be at cost. Value $102,000 of stock at its $185,000 sticker price and you've understated COGS by $83,000 and invented profit that never existed.
  3. Freight-out buried in COGS. Customer shipping is a selling cost. Mixed in with product cost, it makes gross margin move with shipping rates instead of with pricing.
  4. Cutoff errors at period end. Goods received on the 30th but invoiced on the 3rd — or shipped on the 31st and counted anyway — land the cost in the wrong period. Same annual total, two distorted months. Worth a line on your month-end close checklist.
  5. Never separating direct from indirect at all. Service businesses especially: one giant Wages account below gross profit, and the P&L can no longer answer whether the work itself makes money.

Gross Profit That's Right Without the Spreadsheet

BizBooks Pro treats Cost of Goods Sold as a first-class account type, so gross profit is a real subtotal on every income statement, not something you assemble afterwards. Perpetual inventory posts the COGS entry automatically on each sale, per-item costing runs FIFO, LIFO, or weighted average, and it's GAAP-compliant double-entry accounting on your own computer — one flat annual price, no monthly fees.

Start Free 30-Day Trial Try Live Demo

What to Do With the Number Once You Have It

What is a good gross profit margin?

Gross margin is gross profit divided by revenue — Northgate's $228,000 on $520,000 is 43.8%. There's no universal target, because the honest benchmark is industry-specific: grocery retail lives in the teens and low twenties, specialty retail commonly runs 35–50%, and professional services often clear 50% or more. Comparing yourself to a business in a different industry tells you nothing.

What does tell you something is your own trend. Track gross margin as a percentage every month. A steady 44% that slides to 38% over two quarters is a real signal — supplier price increases you didn't pass on, discounting that crept in, a product mix shifting toward your thinner lines, or inventory going missing. Any of those is worth catching in month three rather than at year end. Gross margin sits alongside the other numbers in our roundup of financial ratios every small business owner should track.

The Bottom Line

Cost of goods sold is three numbers and one subtraction, and almost all the difficulty lives in the classification rather than the arithmetic. Get the direct-versus-indirect split right, keep freight-in and freight-out on opposite sides of the gross profit line, value ending inventory at cost, and pick one costing method and stick to it. Do that and gross profit becomes the most useful line on your income statement — the one that tells you whether the thing you sell makes money before overhead ever enters the conversation.

Want the entries to click? Our free interactive double-entry accounting course lets you practice inventory and COGS entries in a hands-on sandbox at your own pace.

Frequently Asked Questions

What is the formula for cost of goods sold?

Cost of goods sold equals beginning inventory plus purchases during the period minus ending inventory. If you started the year with $84,000 of stock, bought $310,000 more including freight-in, and counted $102,000 still on the shelf at year end, your COGS is $292,000. The logic is simple: everything you had available to sell, less what you didn't sell, is what you sold. Manufacturers use the same shape but substitute cost of goods manufactured for purchases.

What is included in cost of goods sold?

COGS includes the direct costs of producing or acquiring what you sold: the purchase price of the goods, raw materials, freight-in and import duty, direct labor for the people who build or deliver the product, subcontractors on billable work, and manufacturing overhead like factory rent and production equipment depreciation. It excludes anything you'd still spend if you sold nothing next month — office salaries, marketing, rent on the admin office, software subscriptions, insurance, and shipping the order out to your customer.

Is shipping included in cost of goods sold?

It depends which direction the parcel is going. Freight-in — what you pay to get inventory to your warehouse — is part of the cost of that inventory and lands in COGS when the item sells. Freight-out, what you pay to ship an order to a customer, is a selling expense and belongs in operating expenses. The same courier invoice can therefore split across two lines of your profit and loss statement, and it's worth splitting because mixing the two distorts gross margin.

Do service businesses have cost of goods sold?

Yes, though it's usually labelled cost of services or cost of revenue. If you sell people's time, the direct cost is the wages and payroll taxes of the staff doing billable work, plus subcontractors, project-specific materials, and any per-project licence or permit. Everything else — the office manager, the sales team, rent, software you'd pay for regardless — is an operating expense. Splitting them out gives a service business a real gross margin per job, which is the number that tells you whether your rates work.

What is the difference between COGS and operating expenses?

COGS scales with sales; operating expenses mostly don't. Sell twice as many units and your product cost roughly doubles, while your rent and your bookkeeper's salary stay flat. The practical test is to ask what happens if you sell nothing next month: costs that disappear are direct costs and belong in COGS, costs that arrive anyway are operating expenses. That distinction is what creates the gross profit subtotal on a profit and loss statement, and gross profit is the line that tells you whether the business model works before overhead is even considered.

Is a higher or lower cost of goods sold better?

Lower COGS relative to sales is better, because it leaves more gross profit to cover overhead. But a COGS figure that suddenly drops is more often an error than a win — the usual causes are inventory counted at the wrong value, purchases posted to an expense account instead of inventory, or a missed period cutoff. Compare COGS as a percentage of sales month over month rather than in dollars, and investigate any swing of more than a few points before you celebrate it.

Related Articles

Get the next guide by email

We publish one plain-English accounting guide a month. No daily digest, no sales sequence — just the new piece when it goes live.

One email a month. Unsubscribe from any of them in one click.