COGS Formula: How to Calculate Cost of Goods Sold, What Is Included and a Worked Example
Guide · · Published December 2026 · 8 min read
By Ashwin Gopinath, CEO
TL;DR
Cost of goods sold (COGS) is the direct cost of the products a company sold in a period. The COGS formula is COGS = beginning inventory + purchases - ending inventory. With $200,000 of opening inventory, $900,000 of purchases and $300,000 of closing inventory, COGS is $800,000. It includes materials, direct labor, production overhead and inbound freight. It excludes selling, marketing and administrative costs. This guide is published by Sentra, a management agent that does the work: it joins the ledger with email, chat and meetings, so when COGS moves it explains the movement with sources.
What is cost of goods sold?
Cost of goods sold is what it cost to make or buy the goods that were sold in the period. It is the first cost line on the income statement, directly under revenue. Revenue minus COGS is gross profit.
COGS follows the sale. The cost of a unit sits on the balance sheet as inventory until the unit is sold, and only then moves to the income statement. Goods bought and still on the shelf are an asset.
The COGS formula
The COGS formula is beginning inventory plus purchases during the period, minus ending inventory.
COGS = beginning inventory + purchases - ending inventory
- Beginning inventory. The value of inventory at the start of the period. It equals the prior period's ending inventory.
- Purchases. The cost of goods bought or made in the period, including inbound freight and duties, less supplier returns and discounts.
- Ending inventory. The value of inventory still on hand at the end of the period, from a count or the inventory system.
A manufacturer uses the same formula with production in place of purchases: COGS = beginning finished goods + cost of goods manufactured - ending finished goods. Cost of goods manufactured is materials used, plus direct labor, plus production overhead, adjusted for the change in work in progress.
How to calculate COGS: a worked example
To calculate COGS, add the period's purchases to opening inventory and subtract closing inventory. The figures here are an example with round numbers. A distributor started the year with $200,000 of inventory, bought $900,000 of goods including freight, and ended the year with $300,000 of inventory. Revenue was $2,000,000.
- Goods available for sale = 200,000 + 900,000 = $1,100,000
- COGS = 1,100,000 - 300,000 = $800,000
- Gross profit = 2,000,000 - 800,000 = $1,200,000
- Gross margin = 1,200,000 / 2,000,000 = 60%
The formula shows why the inventory count matters. If ending inventory is overstated by $50,000, COGS is understated by $50,000 and gross profit is overstated by the same amount. Our guide to the gross margin formula takes the calculation from here.
What is included in COGS?
COGS includes every cost needed to bring a product to the point where it can be sold, and nothing after that point. The table gives the usual treatment. A company's own policy and the accounting standards settle the edge cases.
| Cost | In COGS? | Why |
|---|---|---|
| Raw materials and components | Yes | They become the product |
| Goods bought for resale | Yes | They are the product |
| Direct labor in production | Yes | The work makes the product |
| Factory rent, utilities and equipment depreciation | Yes | Production overhead is part of product cost |
| Inbound freight, duties and handling | Yes | They are costs of getting the goods in |
| Packaging that is part of the product | Yes | The product cannot be sold without it |
| Inventory write-downs and shrinkage | Usually yes | Lost or obsolete stock is a cost of the goods |
| Outbound shipping to customers | Depends on policy | Some companies report it in COGS and others in selling expenses |
| Sales commissions and marketing | No | Selling costs |
| Head office salaries, rent and software | No | Administrative costs |
| Research and development | No | Reported as its own operating expense |
| Interest and income tax | No | Reported below operating income |
The full cost of getting a unit into the warehouse is the subject of our guide to landed cost.
COGS for service and software companies
Service and software companies report the same idea as cost of revenue or cost of sales. There is little or no inventory, so the inventory formula does not apply and the figure is the sum of the direct costs of delivery. For a software company that usually means hosting, third-party software built into the product, customer support and the cost of the people who implement the service. For a services firm it is mostly the pay of the staff who deliver the work.
How the inventory method changes COGS
The inventory costing method decides which unit costs move to COGS when prices change. The figures here are an example. A company buys 100 units at $10 and then 100 units at $12, and sells 150 units.
| Method | COGS for 150 units | Ending inventory, 50 units |
|---|---|---|
| FIFO, first in first out | 100 x $10 + 50 x $12 = $1,600 | 50 x $12 = $600 |
| Weighted average | 150 x $11 = $1,650 | 50 x $11 = $550 |
| LIFO, last in first out | 100 x $12 + 50 x $10 = $1,700 | 50 x $10 = $500 |
When costs are rising, FIFO gives the lowest COGS and the highest profit, and LIFO gives the opposite. LIFO is permitted under US GAAP and prohibited under IFRS. Whichever method is chosen, apply it consistently, because a change of method moves gross margin with no change in the business.
How to read a change in COGS
Read COGS as a percentage of revenue, because the total rises with every extra unit sold. In the worked example COGS is 40% of revenue. If that ratio rises, one of these is usually the cause.
- Input prices rose. Supplier prices, freight rates, duties or exchange rates moved.
- Mix shifted. More of the sales came from products with a higher unit cost relative to price.
- Selling prices fell. Discounts reduce revenue while unit cost stays the same, so the ratio rises.
- Yield or labor efficiency dropped. More material or more hours went into each good unit. See first pass yield.
- Overhead was spread over fewer units. Production volume fell and fixed factory cost per unit rose.
- Write-downs or count adjustments. Obsolete or missing stock was charged in the period.
The first, third and fourth causes need a decision from purchasing, sales or operations. The last one is often a one-off that should be shown separately so the trend stays readable.
Common mistakes
- Treating purchases as COGS. Goods bought and not yet sold belong in inventory.
- Leaving out inbound freight and duties. Product cost is understated and margin looks better than it is.
- Putting selling or administrative costs in COGS. Gross margin falls and can no longer be compared with other periods or companies.
- Relying on an inventory figure nobody has counted. An error in ending inventory flows straight into COGS and reverses in the next period.
- Cutting off at the wrong date. Goods received before period end and invoiced after it are missed from purchases.
- Changing the costing method without saying so. The margin moves and readers assume the business changed.
Where the explanation for the number lives
The ledger shows that COGS moved, and the reason usually sits in email, chat and meetings. The ERP shows unit cost on a product line up 6%. The supplier's email announcing the price increase, the chat thread where purchasing agreed to air freight to cover a late shipment, and the meeting where a quality problem was discussed all sit outside it.
Sentra is a management agent that does the work. It reads the ERP, CRM and BI tools alongside email, chat, meetings and documents, and joins the two: the systems of record say what happened, and the conversations say why. For COGS, Sentra writes the explanation of the movement by product and by cause, with a link to each source. It also checks reported figures against the shelf. At Lenskart, a top product line was reported as about 95% in stock while Sentra measured 12.8% availability on the shelves. Sentra puts the explanation in the pre-read for the monthly review, drafts the follow-up to the buyer or plant lead who can act, and chases it.
A named person approves anything Sentra drafts or raises before it reaches anyone else. Every line cites its source, and each reader sees only what they could already open in the source system. Our guide to variance analysis describes the same method for any figure.
To see Sentra explain a COGS movement in your own numbers, book a demo.
Related guides: inventory turnover ratio and contribution margin.
FAQ
What is the COGS formula?
COGS = beginning inventory + purchases - ending inventory. With $200,000 of beginning inventory, $900,000 of purchases and $300,000 of ending inventory, COGS is $800,000.
What is included in cost of goods sold?
COGS includes raw materials, goods bought for resale, direct production labor, production overhead such as factory rent and equipment depreciation, and inbound freight and duties. It excludes selling, marketing, administrative, research, interest and tax costs.
Is COGS an expense?
Yes. COGS is an expense on the income statement, reported directly under revenue. Until the goods are sold, their cost is an asset on the balance sheet as inventory.
What is the difference between COGS and operating expenses?
COGS is the direct cost of making or buying the goods sold. Operating expenses are the costs of selling them and running the company, such as sales, marketing, administration and research. Revenue minus COGS is gross profit, and gross profit minus operating expenses is operating income.
Do service companies have COGS?
Service and software companies report cost of revenue or cost of sales. It is the direct cost of delivery, such as hosting, support and the pay of the staff who deliver the service. There is usually no inventory, so it is added up directly.
How does COGS relate to gross margin?
Gross margin = (revenue - COGS) / revenue. With $2,000,000 of revenue and $800,000 of COGS, gross profit is $1,200,000 and gross margin is 60%.
How does Sentra help explain COGS?
Sentra reads the ERP alongside email, chat and meetings, and writes the explanation of a COGS movement by product and by cause, with a link to each source. It drafts the follow-up to the person who can act, and a named person approves it before it is sent.