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
Direct cost of the products you sold during the period.
Value of inventory at the start of the period (same as prior period's ending).
All inventory bought (and freight-in) during the period.
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.
COGS Formula Variations
Related calculations for cost and margin
The standard formula. Use consistent inventory valuation (FIFO, LIFO, weighted average).
Useful for estimates; margin must be as a decimal (e.g. 0.45 for 45%).
The bridge between revenue and operating income.
Expressed as a percentage for benchmarking.
Worked Examples
Basic COGS Calculation
Beginning inventory $15,000; purchases during the month $52,000; ending inventory $18,000.
- 1 Beginning Inventory: $15,000
- 2 Add Purchases: $15,000 + $52,000 = $67,000
- 3 Subtract Ending Inventory: $67,000 − $18,000 = $49,000
- 4 COGS = $49,000
Your Cost of Goods Sold for the period is $49,000.
You sold $49,000 worth of product (at cost). Use this with revenue to get gross profit and margin.
COGS and Gross Margin
Revenue for the month was $95,000. COGS (from inventory formula) is $52,000.
- 1 COGS: $52,000
- 2 Gross Profit: $95,000 − $52,000 = $43,000
- 3 Gross Margin: ($43,000 ÷ $95,000) × 100 = 45.3%
Gross profit is $43,000; gross margin is 45.3%.
You keep 45.3 cents of every dollar of revenue after product costs. Use this to set break-even ROAS and pricing.
Product-Level COGS
Product A: cost $12/unit, sold 400 units. Product B: cost $28/unit, sold 150 units.
- 1 Product A COGS: $12 × 400 = $4,800
- 2 Product B COGS: $28 × 150 = $4,200
- 3 Total COGS: $4,800 + $4,200 = $9,000
Total COGS for these two products is $9,000.
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.
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.
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).
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.
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 CalculatorFrequently 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