Formula Guide

COGS Formula: The Complete
Cost of Goods Sold Guide

Master the COGS formula with step-by-step examples, variations, and how it ties to gross profit and margin.

The COGS Formula

COGS = Beginning Inventory + Purchases − Ending Inventory

Direct cost of the products you sold during the period.

Beginning Inventory

Value of inventory at the start of the period (same as prior period's ending).

Purchases

All inventory bought (and freight-in) during the period.

Ending Inventory

Value of inventory left at the end of the period.

Quick Example

Beginning inventory $20,000 + Purchases $65,000 − Ending inventory $22,000.

COGS = $20,000 + $65,000 − $22,000 = $63,000

Track COGS Automatically

StoreRadar tracks product costs and COGS so you always have accurate gross margin and profitability by product.

Start Free Trial

COGS Formula Variations

Related calculations for cost and margin

Basic COGS
Formula
Beginning Inventory + Purchases − Ending Inventory
Example
$10,000 + $45,000 − $12,000 = $43,000
Use Case
Period-based P&L (monthly, quarterly)

The standard formula. Use consistent inventory valuation (FIFO, LIFO, weighted average).

COGS from Revenue & Margin
Formula
Revenue × (1 − Gross Margin %)
Example
$80,000 × (1 − 0.45) = $44,000
Use Case
When you know revenue and target margin

Useful for estimates; margin must be as a decimal (e.g. 0.45 for 45%).

Gross Profit
Formula
Revenue − COGS
Example
$80,000 − $44,000 = $36,000
Use Case
Dollar profit before operating expenses

The bridge between revenue and operating income.

Gross Margin %
Formula
((Revenue − COGS) ÷ Revenue) × 100
Example
($36,000 ÷ $80,000) × 100 = 45%
Use Case
Compare profitability across products and periods

Expressed as a percentage for benchmarking.

Worked Examples

1

Basic COGS Calculation

Scenario

Beginning inventory $15,000; purchases during the month $52,000; ending inventory $18,000.

  1. 1 Beginning Inventory: $15,000
  2. 2 Add Purchases: $15,000 + $52,000 = $67,000
  3. 3 Subtract Ending Inventory: $67,000 − $18,000 = $49,000
  4. 4 COGS = $49,000
Result

Your Cost of Goods Sold for the period is $49,000.

Interpretation

You sold $49,000 worth of product (at cost). Use this with revenue to get gross profit and margin.

2

COGS and Gross Margin

Scenario

Revenue for the month was $95,000. COGS (from inventory formula) is $52,000.

  1. 1 COGS: $52,000
  2. 2 Gross Profit: $95,000 − $52,000 = $43,000
  3. 3 Gross Margin: ($43,000 ÷ $95,000) × 100 = 45.3%
Result

Gross profit is $43,000; gross margin is 45.3%.

Interpretation

You keep 45.3 cents of every dollar of revenue after product costs. Use this to set break-even ROAS and pricing.

3

Product-Level COGS

Scenario

Product A: cost $12/unit, sold 400 units. Product B: cost $28/unit, sold 150 units.

  1. 1 Product A COGS: $12 × 400 = $4,800
  2. 2 Product B COGS: $28 × 150 = $4,200
  3. 3 Total COGS: $4,800 + $4,200 = $9,000
Result

Total COGS for these two products is $9,000.

Interpretation

Product-level COGS reveals which products drive cost. Combine with revenue per product for unit economics.

Common COGS Formula Mistakes

Including Operating Expenses in COGS

Marketing, rent, and salaries are not COGS. Adding them inflates COGS and understates gross margin.

How to Fix

Keep COGS to direct product costs only. Subtract operating expenses from gross profit to get operating income.

Inconsistent Inventory Valuation

Switching between FIFO, LIFO, or weighted average mid-period distorts COGS and comparability.

How to Fix

Choose one method and use it consistently. Document it in your accounting policy.

Forgetting Inbound Shipping

Freight-in to receive inventory is part of product cost and should be in COGS (or allocated to inventory then COGS).

How to Fix

Include freight-in in purchases or add it to inventory cost; it flows through to COGS when you sell.

Not Tracking by Product

Store-wide COGS hides unprofitable products and overstates margin on winners.

How to Fix

Track cost per product and calculate product-level COGS and margin to price and promote correctly.

Related Ecommerce Formulas

Formula Calculation Relationship
Gross Margin ((Revenue − COGS) ÷ Revenue) × 100 COGS is the cost input; gross margin is the profitability percentage.
Break-Even ROAS 1 ÷ Gross Margin Higher COGS (lower margin) means you need higher ROAS to be profitable on ads.
Inventory Turnover COGS ÷ Average Inventory Uses COGS to measure how quickly you sell through inventory.
Markup ((Price − Cost) ÷ Cost) × 100 Markup is on cost; margin is on price. COGS is your cost base.

Need to calculate COGS?

Use COGS Calculator

Frequently Asked Questions

Common questions about the COGS formula

The basic COGS formula is: COGS = Beginning Inventory + Purchases − Ending Inventory. Beginning inventory is what you had at the start of the period; add all purchases (including freight-in); subtract ending inventory (what's left unsold). The result is the cost of the goods you actually sold.

COGS includes direct costs to produce or acquire products: purchase price, raw materials, direct labor, manufacturing overhead, and inbound shipping (freight-in). It excludes marketing, rent, salaries, outbound shipping to customers, and other operating expenses.

COGS is the direct cost of the products sold. Gross profit = Revenue − COGS. Gross margin is gross profit as a percentage of revenue: ((Revenue − COGS) ÷ Revenue) × 100. COGS is the input; gross profit and margin are the outputs.

For a single product: COGS per unit = Cost to acquire or make one unit (including inbound shipping, packaging if direct). Total COGS for that product = COGS per unit × Units sold. Use the same cost method (FIFO, LIFO, or weighted average) consistently.

Inbound shipping (getting inventory to your warehouse) is typically included in COGS. Outbound shipping to customers is usually a selling expense, not COGS. Check your accounting policy and stick to it for consistency.

Many businesses calculate COGS monthly for management reporting and at least quarterly/annually for financial statements. Ecommerce with high volume benefits from real-time or daily COGS tracking for pricing and profitability decisions.

Track COGS Automatically

StoreRadar tracks product costs and COGS so you have accurate margins and can set the right prices and ad targets.

Start Free Trial ->

By signing up, you agree to our Terms of Service and Privacy Policy