# Cost of Goods Sold (COGS): Computation, Formula, and What It Reveals About a Business

Published: 2026-04-03
Author: Warren Team
URL: https://www.heywarren.com/blog/cost-of-goods-sold-computation

---
Cost of Goods Sold is the single most important expense line on any income statement, it determines gross margin, reveals operational efficiency, and is the starting point for nearly every profitability analysis. Here's exactly how it's computed, the different methods used, and what variations in COGS tell you about a business.

## What Is COGS?

**[Cost of Goods Sold (COGS)](/blog/formula-for-cogs)** is the direct cost attributable to the production of goods sold by a company during a period. It includes the raw materials and direct labor consumed in producing those goods, and typically excludes indirect expenses like sales, distribution, and administrative costs.

**Revenue − COGS = Gross Profit**

**Gross Profit / Revenue = Gross Margin**

For retailers, COGS is often called "Cost of Sales." For service companies, a similar concept is "Cost of Services" or "Cost of Revenue." [GAAP](https://www.fasb.org/) and [IFRS](https://www.ifrs.org/) allow flexibility in terminology.

## The Core Formula

**COGS = Beginning Inventory + Purchases − Ending Inventory**

![How beginning inventory, purchases, and ending inventory combine to produce COGS.](data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20875%20125%22%20width%3D%22875%22%20height%3D%22125%22%20role%3D%22img%22%3E%3Ctitle%3EFlow%20diagram%3C%2Ftitle%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22%23f8fafc%22%2F%3E%3Crect%20x%3D%2230%22%20y%3D%2225%22%20width%3D%22170%22%20height%3D%2275%22%20rx%3D%2210%22%20fill%3D%22white%22%20stroke%3D%22%232563eb%22%20stroke-width%3D%222%22%2F%3E%3Ctext%20x%3D%22115%22%20y%3D%2258.5%22%20text-anchor%3D%22middle%22%20font-family%3D%22system-ui%2C-apple-system%2Csans-serif%22%20font-size%3D%2214%22%20font-weight%3D%22600%22%20fill%3D%22%230f172a%22%3EBeginning%20Inventory%3C%2Ftext%3E%3Ctext%20x%3D%22115%22%20y%3D%2278.5%22%20text-anchor%3D%22middle%22%20font-family%3D%22system-ui%2C-apple-system%2Csans-serif%22%20font-size%3D%2211%22%20fill%3D%22%2364748b%22%3E%24500%2C000%3C%2Ftext%3E%3Cline%20x1%3D%22205%22%20y1%3D%2262.5%22%20x2%3D%22237%22%20y2%3D%2262.5%22%20stroke%3D%22%2364748b%22%20stroke-width%3D%222%22%2F%3E%3Cpolygon%20points%3D%22244%2C62.5%20235%2C57.5%20235%2C67.5%22%20fill%3D%22%2364748b%22%2F%3E%3Crect%20x%3D%22245%22%20y%3D%2225%22%20width%3D%22170%22%20height%3D%2275%22%20rx%3D%2210%22%20fill%3D%22white%22%20stroke%3D%22%232563eb%22%20stroke-width%3D%222%22%2F%3E%3Ctext%20x%3D%22330%22%20y%3D%2258.5%22%20text-anchor%3D%22middle%22%20font-family%3D%22system-ui%2C-apple-system%2Csans-serif%22%20font-size%3D%2214%22%20font-weight%3D%22600%22%20fill%3D%22%230f172a%22%3E%2B%20Purchases%3C%2Ftext%3E%3Ctext%20x%3D%22330%22%20y%3D%2278.5%22%20text-anchor%3D%22middle%22%20font-family%3D%22system-ui%2C-apple-system%2Csans-serif%22%20font-size%3D%2211%22%20fill%3D%22%2364748b%22%3E%243%2C200%2C000%3C%2Ftext%3E%3Cline%20x1%3D%22420%22%20y1%3D%2262.5%22%20x2%3D%22452%22%20y2%3D%2262.5%22%20stroke%3D%22%2364748b%22%20stroke-width%3D%222%22%2F%3E%3Cpolygon%20points%3D%22459%2C62.5%20450%2C57.5%20450%2C67.5%22%20fill%3D%22%2364748b%22%2F%3E%3Crect%20x%3D%22460%22%20y%3D%2225%22%20width%3D%22170%22%20height%3D%2275%22%20rx%3D%2210%22%20fill%3D%22white%22%20stroke%3D%22%232563eb%22%20stroke-width%3D%222%22%2F%3E%3Ctext%20x%3D%22545%22%20y%3D%2258.5%22%20text-anchor%3D%22middle%22%20font-family%3D%22system-ui%2C-apple-system%2Csans-serif%22%20font-size%3D%2214%22%20font-weight%3D%22600%22%20fill%3D%22%230f172a%22%3E%E2%88%92%20Ending%20Inventory%3C%2Ftext%3E%3Ctext%20x%3D%22545%22%20y%3D%2278.5%22%20text-anchor%3D%22middle%22%20font-family%3D%22system-ui%2C-apple-system%2Csans-serif%22%20font-size%3D%2211%22%20fill%3D%22%2364748b%22%3E%24600%2C000%3C%2Ftext%3E%3Cline%20x1%3D%22635%22%20y1%3D%2262.5%22%20x2%3D%22667%22%20y2%3D%2262.5%22%20stroke%3D%22%2364748b%22%20stroke-width%3D%222%22%2F%3E%3Cpolygon%20points%3D%22674%2C62.5%20665%2C57.5%20665%2C67.5%22%20fill%3D%22%2364748b%22%2F%3E%3Crect%20x%3D%22675%22%20y%3D%2225%22%20width%3D%22170%22%20height%3D%2275%22%20rx%3D%2210%22%20fill%3D%22white%22%20stroke%3D%22%232563eb%22%20stroke-width%3D%222%22%2F%3E%3Ctext%20x%3D%22760%22%20y%3D%2258.5%22%20text-anchor%3D%22middle%22%20font-family%3D%22system-ui%2C-apple-system%2Csans-serif%22%20font-size%3D%2214%22%20font-weight%3D%22600%22%20fill%3D%22%230f172a%22%3E%3D%20COGS%3C%2Ftext%3E%3Ctext%20x%3D%22760%22%20y%3D%2278.5%22%20text-anchor%3D%22middle%22%20font-family%3D%22system-ui%2C-apple-system%2Csans-serif%22%20font-size%3D%2211%22%20fill%3D%22%2364748b%22%3E%243%2C100%2C000%3C%2Ftext%3E%3C%2Fsvg%3E)

*How beginning inventory, purchases, and ending inventory combine to produce COGS.*

This formula works because:
- You start with a certain amount of inventory
- You buy more inventory during the period
- Whatever is left at the end (ending inventory) was not sold
- What's missing from that flow was sold → COGS

**Example**:
- Beginning inventory (Jan 1): $500,000
- Purchases during year: $3,200,000
- Ending inventory (Dec 31): $600,000
- **COGS = $500,000 + $3,200,000 − $600,000 = $3,100,000**

## What's Included in COGS

### Always Included (Direct Costs)

![Direct cost components that flow into COGS versus costs excluded to SG&A.](data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20760%20211%22%20width%3D%22760%22%20height%3D%22211%22%20role%3D%22img%22%3E%3Ctitle%3EHierarchy%3C%2Ftitle%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22%23f8fafc%22%2F%3E%3Crect%20x%3D%22300%22%20y%3D%2220%22%20width%3D%22160%22%20height%3D%2258%22%20rx%3D%228%22%20fill%3D%22%232563eb%22%2F%3E%3Ctext%20x%3D%22380%22%20y%3D%2254%22%20text-anchor%3D%22middle%22%20font-family%3D%22system-ui%2C-apple-system%2Csans-serif%22%20font-size%3D%2214%22%20font-weight%3D%22700%22%20fill%3D%22white%22%3ECOGS%3C%2Ftext%3E%3Cpath%20d%3D%22M%20380%2078%20L%20380%20105.5%20L%20110%20105.5%20L%20110%20133%22%20stroke%3D%22%23cbd5e1%22%20stroke-width%3D%222%22%20fill%3D%22none%22%2F%3E%3Crect%20x%3D%2230%22%20y%3D%22133%22%20width%3D%22160%22%20height%3D%2258%22%20rx%3D%228%22%20fill%3D%22white%22%20stroke%3D%22%230891b2%22%20stroke-width%3D%222%22%2F%3E%3Ctext%20x%3D%22110%22%20y%3D%22158%22%20text-anchor%3D%22middle%22%20font-family%3D%22system-ui%2C-apple-system%2Csans-serif%22%20font-size%3D%2213%22%20font-weight%3D%22600%22%20fill%3D%22%230f172a%22%3ERaw%20Materials%3C%2Ftext%3E%3Ctext%20x%3D%22110%22%20y%3D%22176%22%20text-anchor%3D%22middle%22%20font-family%3D%22system-ui%2C-apple-system%2Csans-serif%22%20font-size%3D%2210%22%20fill%3D%22%2364748b%22%3Einputs%20in%20product%3C%2Ftext%3E%3Cpath%20d%3D%22M%20380%2078%20L%20380%20105.5%20L%20290%20105.5%20L%20290%20133%22%20stroke%3D%22%23cbd5e1%22%20stroke-width%3D%222%22%20fill%3D%22none%22%2F%3E%3Crect%20x%3D%22210%22%20y%3D%22133%22%20width%3D%22160%22%20height%3D%2258%22%20rx%3D%228%22%20fill%3D%22white%22%20stroke%3D%22%230891b2%22%20stroke-width%3D%222%22%2F%3E%3Ctext%20x%3D%22290%22%20y%3D%22158%22%20text-anchor%3D%22middle%22%20font-family%3D%22system-ui%2C-apple-system%2Csans-serif%22%20font-size%3D%2213%22%20font-weight%3D%22600%22%20fill%3D%22%230f172a%22%3EDirect%20Labor%3C%2Ftext%3E%3Ctext%20x%3D%22290%22%20y%3D%22176%22%20text-anchor%3D%22middle%22%20font-family%3D%22system-ui%2C-apple-system%2Csans-serif%22%20font-size%3D%2210%22%20fill%3D%22%2364748b%22%3Eproduction%20workers%3C%2Ftext%3E%3Cpath%20d%3D%22M%20380%2078%20L%20380%20105.5%20L%20470%20105.5%20L%20470%20133%22%20stroke%3D%22%23cbd5e1%22%20stroke-width%3D%222%22%20fill%3D%22none%22%2F%3E%3Crect%20x%3D%22390%22%20y%3D%22133%22%20width%3D%22160%22%20height%3D%2258%22%20rx%3D%228%22%20fill%3D%22white%22%20stroke%3D%22%230891b2%22%20stroke-width%3D%222%22%2F%3E%3Ctext%20x%3D%22470%22%20y%3D%22158%22%20text-anchor%3D%22middle%22%20font-family%3D%22system-ui%2C-apple-system%2Csans-serif%22%20font-size%3D%2213%22%20font-weight%3D%22600%22%20fill%3D%22%230f172a%22%3EMfg%20Overhead%3C%2Ftext%3E%3Ctext%20x%3D%22470%22%20y%3D%22176%22%20text-anchor%3D%22middle%22%20font-family%3D%22system-ui%2C-apple-system%2Csans-serif%22%20font-size%3D%2210%22%20fill%3D%22%2364748b%22%3Efactory%20rent%2C%20utilities%3C%2Ftext%3E%3Cpath%20d%3D%22M%20380%2078%20L%20380%20105.5%20L%20650%20105.5%20L%20650%20133%22%20stroke%3D%22%23cbd5e1%22%20stroke-width%3D%222%22%20fill%3D%22none%22%2F%3E%3Crect%20x%3D%22570%22%20y%3D%22133%22%20width%3D%22160%22%20height%3D%2258%22%20rx%3D%228%22%20fill%3D%22white%22%20stroke%3D%22%230891b2%22%20stroke-width%3D%222%22%2F%3E%3Ctext%20x%3D%22650%22%20y%3D%22158%22%20text-anchor%3D%22middle%22%20font-family%3D%22system-ui%2C-apple-system%2Csans-serif%22%20font-size%3D%2213%22%20font-weight%3D%22600%22%20fill%3D%22%230f172a%22%3EFreight-In%3C%2Ftext%3E%3Ctext%20x%3D%22650%22%20y%3D%22176%22%20text-anchor%3D%22middle%22%20font-family%3D%22system-ui%2C-apple-system%2Csans-serif%22%20font-size%3D%2210%22%20fill%3D%22%2364748b%22%3Einbound%20shipping%3C%2Ftext%3E%3C%2Fsvg%3E)

*Direct cost components that flow into COGS versus costs excluded to SG&A.*

**Raw materials**: The cost of materials that become part of the finished product. For a furniture maker, this is wood, fabric, screws.

**Direct labor**: Wages of workers who directly manufacture the product. For a clothing company, this is the sewing machine operators, not the CEO.

**Manufacturing overhead allocated to products**: Factory rent, utilities, equipment depreciation, allocated to products based on production volumes.

**Freight-in**: Shipping costs to bring raw materials or inventory to the company.

**Import duties and tariffs**: On imported inputs or inventory.

### Sometimes Included (Debatable)

**Shipping to customers**: Usually excluded from COGS and treated as a distribution expense (included in SG&A). But some retailers include shipping in COGS.

**Stock-based compensation for production workers**: Typically included in COGS when tied to manufacturing staff.

**Research and development**: Typically excluded; treated as a separate operating expense.

### Always Excluded

**Sales and marketing expenses**: Part of SG&A or "Selling Expenses."

**General and administrative costs**: Part of SG&A.

**Corporate office expenses**: SG&A.

**Depreciation of non-manufacturing assets**: Part of operating expenses (not COGS), though some companies include all depreciation in COGS.

## Inventory Valuation Methods

The method used to value ending inventory directly affects COGS:

![Same transactions produce different COGS under FIFO vs LIFO during rising prices.](data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20800%20210%22%20width%3D%22800%22%20height%3D%22210%22%20role%3D%22img%22%3E%3Ctitle%3EComparison%3C%2Ftitle%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22%23f8fafc%22%2F%3E%3Ctext%20x%3D%22230%22%20y%3D%2257.5%22%20text-anchor%3D%22end%22%20font-family%3D%22system-ui%2C-apple-system%2Csans-serif%22%20font-size%3D%2214%22%20font-weight%3D%22600%22%20fill%3D%22%230f172a%22%3EFIFO%20COGS%3C%2Ftext%3E%3Crect%20x%3D%22240%22%20y%3D%2225%22%20width%3D%22380.7692307692308%22%20height%3D%2255%22%20rx%3D%226%22%20fill%3D%22%232563eb%22%2F%3E%3Ctext%20x%3D%22632.7692307692307%22%20y%3D%2257.5%22%20font-family%3D%22system-ui%2C-apple-system%2Csans-serif%22%20font-size%3D%2214%22%20font-weight%3D%22700%22%20fill%3D%22%232563eb%22%3E%242.2K%3C%2Ftext%3E%3Ctext%20x%3D%22230%22%20y%3D%22152.5%22%20text-anchor%3D%22end%22%20font-family%3D%22system-ui%2C-apple-system%2Csans-serif%22%20font-size%3D%2214%22%20font-weight%3D%22600%22%20fill%3D%22%230f172a%22%3ELIFO%20COGS%3C%2Ftext%3E%3Crect%20x%3D%22240%22%20y%3D%22120%22%20width%3D%22450%22%20height%3D%2255%22%20rx%3D%226%22%20fill%3D%22%237c3aed%22%2F%3E%3Ctext%20x%3D%22702%22%20y%3D%22152.5%22%20font-family%3D%22system-ui%2C-apple-system%2Csans-serif%22%20font-size%3D%2214%22%20font-weight%3D%22700%22%20fill%3D%22%237c3aed%22%3E%242.6K%3C%2Ftext%3E%3C%2Fsvg%3E)

*Same transactions produce different COGS under FIFO vs LIFO during rising prices.*

### 1. FIFO (First-In, First-Out)

Assumes the oldest inventory is sold first. In inflation, this method:
- Shows higher ending inventory (newer, more expensive stock remains)
- Shows lower COGS
- Shows higher gross profit
- Shows higher net income (and higher taxes)

**Used by**: Many retailers, companies following IFRS (which prohibits LIFO)

### 2. LIFO (Last-In, First-Out)

Assumes the newest inventory is sold first. In inflation, this method:
- Shows lower ending inventory (older, cheaper stock remains)
- Shows higher COGS
- Shows lower gross profit
- Shows lower net income (and lower taxes)

**Used by**: Many US industrial and petroleum companies (only allowed under US GAAP, not IFRS)

**LIFO reserve**: The difference between FIFO and LIFO inventory, disclosed in notes. When commodity prices rise, LIFO reserve grows; "LIFO liquidation" occurs when companies draw down old, low-cost layers and report artificially high margins.

### 3. Weighted Average Cost

Uses the weighted-average cost of all units available during the period. Smooths out price fluctuations.

**Used by**: Many manufacturers, especially where individual units are indistinguishable (chemicals, grains, commodities).

### 4. Specific Identification

Each specific unit is tracked individually. Used for high-value, uniquely identifiable items (cars, fine art, jewelry).

### Impact Comparison Example

A company buys inventory in three batches during a period of rising prices:
- January: 100 units @ $10 = $1,000
- June: 100 units @ $12 = $1,200
- November: 100 units @ $14 = $1,400
- **Total: 300 units, $3,600 cost**

Sells 200 units during the year.

**FIFO COGS**: 100 × $10 + 100 × $12 = $2,200 (ending inventory: 100 × $14 = $1,400)

**LIFO COGS**: 100 × $14 + 100 × $12 = $2,600 (ending inventory: 100 × $10 = $1,000)

**Weighted Average**: 200 × ($3,600/300) = $2,400 (ending inventory: $1,200)

The method choice creates a $400 difference in COGS on the same transactions.

## COGS in a Service or Technology Business

Service and software companies often have significant "Cost of Revenue" that isn't traditional COGS:

**SaaS companies (Salesforce, Adobe, Datadog)**:
- Hosting and infrastructure costs (AWS, Azure)
- Customer support staff tied to accounts
- Third-party software licenses
- Professional services delivery costs

**Financial services (banks, asset managers)**:
- Interest expense (for banks) is "cost" but typically separate from COGS
- Direct portfolio management costs
- Transaction/brokerage fees

**Marketplace businesses (Uber, Airbnb)**:
- Payments to drivers/hosts (the "take rate" is revenue; cost of revenue includes payment processing, insurance, fraud losses)

For SaaS companies especially, the **gross margin** calculated from (Revenue − Cost of Revenue) / Revenue is a key health metric, high-quality SaaS companies target 75-85% gross margins.

## Gross Margin Analysis

Understanding COGS tells you gross margin, one of the most revealing metrics:

**Gross Margin = (Revenue − COGS) / Revenue**

**Typical gross margins by industry**:
- Luxury goods (LVMH, Hermès): 65-75%
- Pharmaceutical majors: 75-85%
- Consumer packaged goods (P&G, Unilever): 40-55%
- Auto manufacturers: 10-20%
- Airlines: Variable; typically 10-30% (cost structure dominated by fuel, labor)
- Grocery stores: 20-30%
- Commodity steel/oil: 10-20% (highly cyclical)
- Software (SaaS): 70-85%
- Semiconductors (NVIDIA): 60-75% (fab-less); 50-60% (foundry like TSMC)
- Discount retail (Walmart, Costco): 20-30%

**What falling gross margins signal**:
1. Commodity input cost inflation
2. Loss of pricing power (competitive pressure)
3. Product mix shift toward lower-margin items
4. Operational inefficiency
5. Deliberate margin sacrifice (e.g., for market share)

**What rising gross margins signal**:
1. Pricing power (premium brands)
2. Input cost deflation
3. Mix shift toward higher-margin products
4. Operational scaling (fixed costs spread over more revenue)

## COGS on the Cash Flow Statement

COGS is recorded on the income statement as an expense when inventory is sold. But the cash flow associated with COGS differs:

**Cash outflow occurred when**:
1. Inventory was purchased/manufactured (earlier period)
2. Payroll (direct labor) was paid

**On the cash flow statement**:
- Net income reflects COGS
- Adjustments for changes in inventory and accounts payable (working capital) reconcile to actual cash flow

When inventory increases, cash flow is lower than net income. When inventory decreases, cash flow is higher than net income.

## Common COGS Calculation Errors

**1. Double-counting overhead**: If overhead is allocated to COGS, it shouldn't also appear in SG&A.

**2. Including non-manufacturing labor**: Sales staff, management, and administrative wages should NOT be in COGS.

**3. Ignoring inventory adjustments**: Obsolescence, shrinkage, write-downs affect COGS (they're expensed to COGS).

**4. Wrong inventory method**: Changing methods requires disclosure and restatement; inconsistent application creates distorted comparisons.

**5. Missing freight-in**: Shipping costs to bring inventory to the company are part of inventory cost (capitalized), not an immediate expense.

## Conclusion

COGS computation is simple in concept, Beginning Inventory + Purchases − Ending Inventory, but the choice of inventory method, what's included in direct vs. indirect costs, and how overhead is allocated can produce materially different results on the same underlying transactions. For investors, tracking gross margin over time and comparing against industry peers reveals pricing power, cost discipline, and operational quality. For management, COGS control is often where operational improvements have the biggest bottom-line impact.

For related financial analysis topics, see our guides on [inventory turnover](/blog/inventory-turnover), [profit and loss statements](/blog/profit-and-loss-statement), and [marginal cost](/blog/marginal-cost).

Warren at [heywarren.com](https://heywarren.com) analyzes gross margins and COGS trends across your watchlist to identify quality businesses with durable pricing power.

---


## Related Reading

**More from Warren**:
- [Bills Payable: Definition, Examples, and How They Differ From Accounts Payable](/blog/bills-payable)
- [Accounts Receivable: What It Is, How It Works, and Why It Matters](/blog/accounts-receivable)
- [Pro Forma Invoice: What It Is, How It Differs From a Commercial Invoice, and When to Use One](/blog/pro-forma-invoice)

**Authoritative sources**:
- [FASB, Accounting Standards Codification](https://asc.fasb.org/)
- [AICPA, Financial Reporting](https://www.aicpa-cima.com/topic/audit-assurance/financial-reporting)
- [SEC EDGAR, Company Filings](https://www.sec.gov/edgar/searchedgar/companysearch)
