How Cost of Goods Sold is calculated
Cost of Goods Sold (COGS) is the direct cost attributable to producing or purchasing the goods a business sells during a period. It appears on the income statement immediately below revenue and is subtracted to give gross profit. COGS is the most important cost line for any product business because it directly determines gross margin, which sets the ceiling for all profitability. A business with insufficient gross margin cannot cover its operating expenses regardless of revenue growth.
The periodic inventory method — the most common approach for small and medium businesses — calculates COGS from three inventory measurements: beginning inventory (goods on hand at the start of the period), purchases or production costs added during the period, and ending inventory (goods on hand at the end). Any inventory that was available to sell but is no longer on hand must have been sold, and therefore represents COGS.
The COGS formula and its components
COGS = Beginning Inventory + Purchases − Ending Inventory
Total COGS = Inventory COGS + Direct Labour + Manufacturing Overhead + Other Direct Costs
Gross Profit = Revenue − COGS
Gross Margin % = (Gross Profit ÷ Revenue) × 100
Markup % = (Gross Profit ÷ COGS) × 100
FIFO COGS = cost of oldest units × units sold
LIFO COGS = cost of newest units × units sold
Weighted avg. COGS = (total cost of goods available ÷ total units) × units sold
Gross margin is calculated from the revenue perspective (profit divided by revenue). Markup is calculated from the cost perspective (profit divided by cost). A 40% gross margin corresponds to a 66.7% markup on cost. They are not the same figure and are not interchangeable.
Inventory valuation methods compared
| Method | COGS assumption | In rising price environment | Ending inventory value | Tax impact |
| Periodic (standard) | Total available minus ending | Neutral (depends on actuals) | Based on count & actual cost | Neutral |
| FIFO | Oldest costs leave first | Lower COGS, higher profit | Higher (recent prices) | Higher tax in rising markets |
| LIFO | Newest costs leave first | Higher COGS, lower profit | Lower (older prices) | Lower tax in rising markets |
| Weighted average | Blended cost per unit | Moderate COGS | Moderate | Moderate |
COGS vs operating expenses
A critical accounting distinction is the line between COGS and operating expenses (OpEx). COGS includes only the costs directly tied to producing or purchasing what was sold. Every other business cost — marketing, sales, administration, R&D, interest, rent for non-production space — belongs in operating expenses and is deducted below the gross profit line. Misclassifying operating expenses as COGS inflates COGS, depresses gross margin, and gives a false picture of product economics. This matters for benchmarking, investor analysis, and pricing decisions.
Worked examples
Example 1: Retail business, single product line
A clothing retailer begins the year with $40,000 of inventory. During the year it purchases $120,000 of new stock. At year-end, $30,000 of inventory remains unsold. COGS = $40,000 + $120,000 − $30,000 = $130,000. If revenue is $200,000, gross profit = $70,000 and gross margin = 35%. Markup on cost = $70,000 ÷ $130,000 = 53.8%. For retail this falls within the typical 25%–45% gross margin range.
Example 2: Manufacturer with direct labour and overhead
A furniture manufacturer has: beginning inventory $25,000, raw material purchases $80,000, ending inventory $20,000. Inventory COGS = $85,000. Direct labour = $40,000. Manufacturing overhead (factory depreciation, utilities) = $15,000. Total COGS = $85,000 + $40,000 + $15,000 = $140,000. If revenue = $210,000, gross profit = $70,000, gross margin = 33.3%. Manufacturing benchmarks of 20%–40% confirm this is healthy.
Example 3: FIFO vs LIFO impact on COGS
A business buys 100 units at $10 (Batch 1) and 100 units at $14 (Batch 2). It sells 120 units. Under FIFO: sell 100 from Batch 1 + 20 from Batch 2 = $1,000 + $280 = $1,280 COGS. Under LIFO: sell 100 from Batch 2 + 20 from Batch 1 = $1,400 + $200 = $1,600 COGS. The $320 difference directly reduces gross profit under LIFO, lowering taxable income when costs are rising.
| Business type | Revenue | COGS | Gross profit | Gross margin | Markup |
| Clothing retailer | $200,000 | $130,000 | $70,000 | 35.0% | 53.8% |
| Furniture manufacturer | $210,000 | $140,000 | $70,000 | 33.3% | 50.0% |
| SaaS company | $500,000 | $75,000 | $425,000 | 85.0% | 566.7% |
| Restaurant | $300,000 | $195,000 | $105,000 | 35.0% | 53.8% |
| Wholesale distributor | $1,000,000 | $750,000 | $250,000 | 25.0% | 33.3% |
Frequently Asked Questions
What is the difference between gross margin and markup?+
Gross margin is calculated as gross profit divided by revenue, expressed as a percentage. Markup is calculated as gross profit divided by COGS (the cost), expressed as a percentage. They use the same gross profit numerator but different denominators, so they produce different numbers for the same product. A product that costs $60 and sells for $100 has a gross profit of $40. Gross margin = $40 / $100 = 40%. Markup = $40 / $60 = 66.7%. The distinction matters because pricing decisions typically use markup (you start with cost and add a percentage), while financial reporting and benchmarking use gross margin (you start with revenue and measure what is left after direct costs). Confusing the two leads to systematic pricing errors.
Which inventory valuation method should I use?+
The right method depends on your industry, tax jurisdiction, and reporting requirements. FIFO is the most widely accepted internationally (required under IFRS) and produces the highest ending inventory value and most accurate balance sheet in rising price environments. LIFO is permitted under US GAAP and is used by some US businesses specifically to reduce taxable income when input costs are rising, because it pushes higher recent costs into COGS. Weighted average is common for businesses with homogeneous inventory (grain, oil, chemicals) where tracking individual batches is impractical. Note that LIFO is not permitted under IFRS, so businesses reporting under IFRS or planning international expansion should use FIFO or weighted average.
What costs are not included in COGS?+
COGS includes only the direct costs of producing or purchasing the goods that were sold. The following are not COGS: selling and marketing expenses (advertising, sales commissions, trade shows), general and administrative expenses (office rent, management salaries, legal fees, accounting), research and development costs, interest expense, depreciation on non-production assets, and any costs incurred for goods not yet sold (which remain in ending inventory). For service businesses, indirect salaries (management, support staff not directly billable to clients) and office overhead typically belong in operating expenses, not COGS, unless the business explicitly accounts for all service delivery costs at the gross margin line.
How do I calculate COGS if I do not track inventory?+
Service businesses and digital product businesses without physical inventory can calculate COGS by directly summing the costs attributable to the revenue earned in the period: direct labour hours billed to projects, contractor payments, hosting and infrastructure costs, software licences directly tied to service delivery, and any direct material costs. There is no beginning or ending inventory figure to work with. The periodic formula does not apply. Many SaaS companies define COGS as hosting, customer support, and third-party costs attributable to running the product, which is why SaaS gross margins of 70% to 85% are achievable. The correct approach is to identify every cost that would disappear if you stopped serving customers, and include only those in COGS.
Why is gross margin important for investors?+
Gross margin is the first profitability test investors apply to any business. It reveals whether the core business model is viable before any operating expenses are considered. A business with 20% gross margin needs very low operating expenses to reach profitability; a business with 70% gross margin has much more room to invest in growth. In SaaS, investors routinely demand gross margins above 70% before Series A. For product companies the bar varies by industry but any gross margin below 20% is typically considered too thin unless the business operates at extreme volume. Gross margin also drives valuation multiples: high-margin businesses trade at significantly higher revenue multiples than low-margin ones because the same revenue line implies much more potential profit.
How can I improve my COGS and gross margin?+
There are four primary levers for improving gross margin. First, reduce input costs by negotiating supplier terms, increasing order volumes to access volume pricing, or sourcing alternative suppliers. Second, improve production efficiency by reducing waste, improving yield rates, and automating direct labour steps. Third, raise prices, which is often more impactful than cost reduction because a 5% price increase on $500,000 revenue adds $25,000 gross profit with no corresponding cost increase. Fourth, shift the product mix toward higher-margin lines by discontinuing low-margin products or actively promoting higher-margin offerings. This calculator identifies which product lines are dragging down your overall margin, making the mix shift decision visible.