# Cost of Goods Sold (COGS): Formula, Calculation, and What It Includes

Published: 2026-01-22
Author: Warren Team
URL: https://www.heywarren.com/blog/formula-for-cogs

---
The [Cost of Goods Sold (COGS)](/blog/cost-of-goods-sold-computation) formula calculates the direct costs of producing the goods a company sold during a period. COGS is the first major expense line on the income statement, subtracted from revenue to arrive at gross profit. The standard COGS formula is: Beginning Inventory + Purchases (or Cost of Production) − Ending Inventory. For a retailer with $50,000 of beginning inventory, $200,000 in purchases, and $45,000 of ending inventory, COGS = $205,000. Understanding COGS, what it includes, how inventory accounting methods (FIFO, LIFO, weighted average) affect it, and what it excludes, is foundational for financial statement analysis, pricing strategy, and gross margin management.

## The COGS Formula

**For retail and wholesale companies**:

![How beginning inventory, purchases, and ending inventory combine to produce COGS for a retailer.](data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%201090%20125%22%20width%3D%221090%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%2445%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%24185%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%3EAvailable%20for%20Sale%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%24230%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%E2%88%92%20Ending%20Inventory%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%2452%2C000%3C%2Ftext%3E%3Cline%20x1%3D%22850%22%20y1%3D%2262.5%22%20x2%3D%22882%22%20y2%3D%2262.5%22%20stroke%3D%22%2364748b%22%20stroke-width%3D%222%22%2F%3E%3Cpolygon%20points%3D%22889%2C62.5%20880%2C57.5%20880%2C67.5%22%20fill%3D%22%2364748b%22%2F%3E%3Crect%20x%3D%22890%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%22975%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%3ECOGS%3C%2Ftext%3E%3Ctext%20x%3D%22975%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%24178%2C000%3C%2Ftext%3E%3C%2Fsvg%3E)

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

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

**For manufacturing companies**:

> **COGS = Beginning Finished Goods + Cost of Goods Manufactured − Ending Finished Goods**

Where:
> **Cost of Goods Manufactured = Direct Materials Used + Direct Labour + Manufacturing Overhead**

**Retail example**:
| Item | Amount |
|---|---|
| Beginning inventory (Jan 1) | $45,000 |
| + Purchases during period | $185,000 |
| = Cost of goods available for sale | $230,000 |
| − Ending inventory (Dec 31) | $52,000 |
| **= COGS** | **$178,000** |

**Manufacturing example**:
- Direct materials: $80,000
- Direct labour: $45,000
- Manufacturing overhead (allocated): $25,000
- Cost of goods manufactured: $150,000
- Beginning finished goods: $30,000
- Ending finished goods: $22,000
- **COGS: $158,000**

## What Is Included in COGS?

COGS includes only the **direct costs** of producing or acquiring the goods that were sold:

![Direct cost categories that flow into COGS for manufacturers versus retailers.](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%3Ecomponents%20used%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%20Labour%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%20costs%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 categories that flow into COGS for manufacturers versus retailers.*

**For manufacturers**:
- Raw materials and components used in production
- Direct labour (wages of workers directly making the product)
- Manufacturing overhead: factory rent, utilities, equipment depreciation, quality control
- Freight-in (shipping cost to receive materials)

**For retailers/wholesalers**:
- Purchase price of goods acquired for resale
- Freight-in and import duties
- Packaging directly related to the product

**NOT included in COGS** (these are operating expenses):
- Selling expenses (sales commissions, advertising)
- General and administrative expenses (CEO salary, accounting)
- R&D costs
- Freight-out (shipping to customers, selling expense)
- Depreciation on non-manufacturing assets

## How Inventory Methods Affect COGS

The inventory costing method chosen dramatically affects COGS and therefore gross profit:

![During inflation, LIFO assigns higher recent costs to COGS, reducing gross profit versus FIFO.](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%22375%22%20height%3D%2255%22%20rx%3D%226%22%20fill%3D%22%232563eb%22%2F%3E%3Ctext%20x%3D%22627%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%24150%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%24180%3C%2Ftext%3E%3C%2Fsvg%3E)

*During inflation, LIFO assigns higher recent costs to COGS, reducing gross profit versus FIFO.*

**FIFO (First In, First Out)**: Oldest inventory costs are assigned to COGS first. During inflation, FIFO produces lower COGS (older, cheaper costs go out) and higher gross profit, but higher taxes.

**LIFO (Last In, First Out)**: Most recent inventory costs assigned to COGS first. During inflation, LIFO produces higher COGS (newer, more expensive costs go out) and lower taxable income, hence LIFO is used by US companies for tax savings. (LIFO is not permitted under [IFRS](https://www.ifrs.org/).)

**Weighted Average Cost**: COGS is calculated at the weighted average cost of all inventory. Smooths the impact of price fluctuations between FIFO and LIFO.

**Specific Identification**: Actual cost of each specific item sold is used. Common for high-value, unique goods (jewellery, cars, custom equipment).

**FIFO vs. LIFO during inflation** (same underlying data):

| Method | COGS | Gross Profit | Taxable Income |
|---|---|---|---|
| FIFO | Lower | Higher | Higher (pays more tax) |
| LIFO | Higher | Lower | Lower (tax deferral) |
| Weighted Average | Middle | Middle | Middle |

## COGS and Gross Margin

**Gross profit = Revenue − COGS**
**Gross margin = Gross profit / Revenue × 100**

COGS is the primary determinant of gross margin, the first measure of business profitability. Gross margin benchmarks by industry:

| Industry | Typical Gross Margin |
|---|---|
| Software (SaaS) | 65%–80% |
| Pharmaceuticals | 60%–80% |
| Consumer electronics | 25%–40% |
| Apparel/retail | 35%–55% |
| Grocery/food retail | 20%–30% |
| Manufacturing (durable goods) | 25%–45% |
| Construction | 15%–25% |

Gross margin measures how efficiently a company produces its goods. Two companies with the same revenue can have very different competitive positions depending on their COGS structure.

## COGS in Analysis and Financial Modelling

**Common COGS analysis**:
- **COGS as % of revenue** (tracked over time): Rising COGS % indicates margin pressure from input cost inflation, inefficiency, or pricing concessions
- **Gross margin trend**: Expanding gross margin = pricing power or cost improvement; contracting = competitive pressure or input cost inflation
- **Inventory days = (Ending Inventory / COGS) × 365**: How many days of COGS is held in inventory; high number may indicate slow-moving or excess inventory

**Common manipulations to watch for**:
- Under-stating ending inventory (inflates COGS, reduces reported gross profit)
- Over-stating beginning inventory (inflates COGS)
- Capitalising costs that should be in COGS (improves reported gross profit temporarily)
- Channel stuffing: recognising revenue on goods shipped but not yet sold, artificially improving COGS%

## Conclusion

The COGS formula, Beginning Inventory + Purchases − Ending Inventory, is the foundation of income statement analysis for goods-producing businesses. COGS determines gross margin, drives pricing strategy, and reflects a company's cost efficiency. The choice of inventory accounting method (FIFO, LIFO, weighted average) affects COGS materially during inflationary periods. Understanding what is and isn't included in COGS, and how it differs from operating expenses, is essential for accurate financial modelling and performance analysis. For related income statement metrics, see our guides on [formula for operating income](/blog/formula-for-operating-income) and [EBITDA margin](/blog/ebitda-margin).

Warren at [heywarren.com](https://heywarren.com) helps analysts, business owners, and finance students calculate COGS accurately, model gross margins, and understand how inventory accounting choices affect reported profitability.

---


## Related Reading

**More from Warren**:
- [Formula for Operating Income: How to Calculate It and Why It Matters](/blog/formula-for-operating-income)
- [EBITDA Margin: What It Is, How to Calculate It, and What It Tells You](/blog/ebitda-margin)
- [LIFO vs. FIFO: How Inventory Methods Affect Cost and Tax](/blog/lifo-versus-fifo)

**Authoritative sources**:
- [FASB ASC 330, Inventory](https://asc.fasb.org/330)
- [IRS, LIFO Inventory Method](https://www.irs.gov/businesses/small-businesses-self-employed/change-in-accounting-method)
- [SEC, Cost of Goods Sold Disclosures](https://www.sec.gov/cgi-bin/browse-edgar)
