Blog · Finance metrics and formulas
Cost of goods sold is the direct cost of the goods a company sold in the period. This page gives the COGS formula, what US GAAP and the IRS put in and leave out, a worked year for a distributor with the Excel formulas, how FIFO, weighted average and LIFO change the figure, and what service companies call cost of revenue.
Cost of goods sold (COGS) is the direct cost of the goods a company sold in the period: the purchase cost of goods bought for resale, or the materials, direct labor and production overhead of goods it made. For a trading business it comes from three inventory figures: opening inventory plus purchases, freight in included, minus closing inventory. Opening inventory of $420,000, purchases of $1,905,000 and closing inventory of $505,000 give COGS of $1,820,000.
COGS = Opening inventory + Purchases + Freight in − Purchase returns − Closing inventory
Opening inventory plus everything bought is the cost of goods available for sale. Whatever is still on the shelf at the end is closing inventory, an asset on the balance sheet; the rest was sold, and its cost is the expense. That is why COGS is measured, not posted invoice by invoice: it depends on the closing count and its valuation.
US GAAP's inventory standard, ASC 330, makes cost the basis for inventory and the IRS takes the same view. Publication 538 defines the cost of purchased merchandise as "the invoice price minus appropriate discounts plus transportation or other charges incurred in acquiring the goods."
| In COGS | Not in COGS |
|---|---|
| Purchase price, net of trade discounts | Selling, marketing and administrative costs |
| Import duties and freight in | Freight out: delivery to customers |
| Direct materials and direct labor (manufacturers) | Abnormal waste, spoilage and idle capacity |
| Production overhead, allocated systematically | Storage, unless part of the production process |
| Inventory write-downs, if that is the policy | Interest on borrowing, in most cases |
SEC filers must say what they put in. Regulation S-X Rule 5-02 requires the basis of inventory to be stated and, where cost is used, "the nature of the cost elements included in inventory", along with the method by which amounts are removed from inventory, "e.g., average cost, first-in, first-out, last-in, first-out". For tax, corporations and partnerships that deduct COGS attach Form 1125-A, which rebuilds the same opening-plus-purchases-minus-closing calculation. IFRS reaches a similar list in IAS 2.
| Row | What | Source |
|---|---|---|
| Opening inventory | Valuation at the start of the period | Last period's closing balance |
| Purchases | Supplier invoices for goods, net of discounts | Purchase ledger |
| Freight in, duties | Charges to bring goods to your site | Purchase ledger or a separate account |
| Purchase returns | Goods sent back to suppliers | Supplier credit memos |
| Closing inventory | Count or perpetual valuation at period end | Inventory system |
All five must share the same cut-off date. A delivery counted in closing inventory needs its invoice, or an accrual for it, in purchases.
One distributor, fiscal year 2026, with no purchase returns. Values in column B:
| Row | Line | Amount (USD) |
|---|---|---|
| 2 | Opening inventory | 420,000 |
| 3 | Purchases | 1,860,000 |
| 4 | Freight in | 45,000 |
| 5 | Closing inventory | 505,000 |
| 6 | Cost of goods sold | 1,820,000 |
| 7 | Revenue | 2,800,000 |
| 8 | Gross profit | 980,000 |
B6: =B2+B3+B4-B5 returns 1,820,000
B9: =B6/B7 COGS ratio, returns 65.0%
B10: =1-B9 gross margin, returns 35.0%
Step by step: goods available are 420,000 + 1,860,000 + 45,000 = 2,325,000. Take off the 505,000 still in stock and 1,820,000 was sold. Purchases including freight in are 1,905,000, the figure in the summary above.
The check: goods available must equal COGS plus closing inventory. 1,820,000 + 505,000 = 2,325,000. And gross profit plus COGS must equal revenue: 980,000 + 1,820,000 = 2,800,000.
COGS ratio = COGS / Revenue
Gross margin = 1 − COGS ratio
COGS of 1,820,000 on revenue of 2,800,000 is a 65.0% COGS ratio, so 35.0% of each sales dollar is left as gross profit. The "COGS margin" people search for is usually one of these two numbers; say which. How gross margin moves with price, cost and mix is on the gross profit margin page, and what comes off below it is in gross profit vs net profit.
The same goods can produce three COGS figures. Opening stock is 100 units at $10.00; the company buys 200 at $11.00, then 200 at $12.00, and sells 350. Goods available: 500 units costing 1,000 + 2,200 + 2,400 = 5,600.
| Method | Which costs go to COGS | COGS (USD) | Closing inventory (USD) |
|---|---|---|---|
| FIFO | 100 × 10 + 200 × 11 + 50 × 12 | 3,800 | 1,800 |
| Weighted average | 350 × 11.20 (5,600 / 500) | 3,920 | 1,680 |
| LIFO | 200 × 12 + 150 × 11 | 4,050 | 1,550 |
Each row sums to 5,600: COGS plus closing inventory is always the cost of goods available. With rising prices, LIFO gives the highest COGS and the lowest profit, which Publication 538 states directly: "in times of inflation, when prices are rising, LIFO will produce a larger cost of goods sold and a lower closing inventory."
LIFO is the US-specific point. It is permitted under US GAAP and for US tax, but a company that uses it for tax must also use it in its reports to shareholders and lenders: the conformity rule in 26 U.S.C. 472(c). IFRS does not allow it; IAS 2 permits only FIFO or weighted average cost for interchangeable items.
A business with no inventory reports cost of revenue or cost of services: delivery staff time, subcontractors, hosting and licenses consumed per customer. The logic is the same as COGS, costs that rise with each unit of revenue delivered, but there is no opening or closing inventory to adjust, so it is posted directly. Regulation S-X lists "cost of services" as its own caption beside cost of tangible goods sold.
A company COGS figure says what the goods cost; it does not say which customers earn a margin on them. Covirage's tools take COGS per invoice line from the ledger export, compute gross margin per product and customer, and reconcile the total to the P&L's cost of sales; the external AI model explains where margin moved and never does the arithmetic. See customer profitability to take gross margin down to each customer and then the cost to serve them, and margin by account for the method. For how fast that cost moves through stock, see inventory turnover ratio and days inventory outstanding, and for pricing on cost, see markup vs margin.
Yes. It is the expense matched to the revenue from goods sold in the period, shown directly below revenue. Until the goods are sold, their cost sits on the balance sheet as inventory.
COGS is the cost of the goods themselves and of making them. Operating expenses are the costs of running the business: selling, marketing, administration and distribution to customers. Gross profit sits between the two.
They usually call it cost of revenue or cost of services: the direct cost of delivering the service, such as delivery staff time, subcontractors and hosting. The logic is the same: costs that rise with each unit of revenue delivered.
Direct labor that makes the product, or delivers the service, is included. Sales, administration and management salaries are operating expenses. Under US GAAP (ASC 330) production overhead is also included on a systematic basis, and US tax rules (section 263A) can require more for larger businesses.