How to Calculate Gross Margin

Gross margin measures the percentage of revenue retained after direct costs. Learn the gross margin formula, industry benchmarks, and how to apply it across different business models.

5 min read·

Gross margin is the percentage of revenue that remains after subtracting the direct costs of producing goods or delivering services. It represents the portion of each revenue dollar available to cover operating expenses and generate profit - making it one of the most fundamental profitability metrics for any business.

Basic Gross Margin Formula

The standard gross margin calculation is:

Gross Margin = (Revenue - Cost of Goods Sold) / Revenue × 100%

Or equivalently:

Gross Margin = Gross Profit / Revenue × 100%

Where:

  • Revenue = Total sales or service income
  • Cost of Goods Sold (COGS) = Direct costs to produce products or deliver services
  • Gross Profit = Revenue minus COGS

Step-by-Step Calculation

Step 1: Calculate Total Revenue

Sum all revenue from sales during the period:

  • Product sales
  • Service fees
  • Subscription revenue
  • Any other direct sales

Exclude non-operating income like interest or investment gains.

Step 2: Identify Cost of Goods Sold

COGS includes direct costs tied to production or delivery:

For Product Companies:

  • Raw materials
  • Direct labor (manufacturing)
  • Manufacturing overhead
  • Shipping and freight
  • Packaging

For SaaS Companies:

  • Hosting and infrastructure costs
  • Third-party software licenses (used in product delivery)
  • Customer support (if included in your COGS definition)
  • Payment processing fees

For Service Companies:

  • Direct labor (billable hours)
  • Materials consumed during service delivery
  • Contractor costs for client work

Step 3: Calculate Gross Profit

Gross Profit = Revenue - COGS

Step 4: Calculate Gross Margin Percentage

Gross Margin = Gross Profit / Revenue × 100%

Example Calculations

SaaS Company Example

Line ItemAmount
Subscription Revenue$500,000
Hosting Costs$40,000
Payment Processing$15,000
Support Team (COGS portion)$45,000
Total COGS$100,000
Gross Profit = $500,000 - $100,000 = $400,000
Gross Margin = $400,000 / $500,000 × 100% = 80%

E-commerce Example

Line ItemAmount
Product Sales$1,000,000
Product Cost$550,000
Shipping$80,000
Packaging$20,000
Total COGS$650,000
Gross Profit = $1,000,000 - $650,000 = $350,000
Gross Margin = $350,000 / $1,000,000 × 100% = 35%

Gross Margin by Segment

Aggregate gross margin can hide important variation. Calculate by product line, customer segment, or channel:

SegmentRevenueCOGSGross Margin
Enterprise$300,000$45,00085%
Mid-Market$150,000$30,00080%
SMB$50,000$15,00070%

Segment analysis reveals which parts of the business are most efficient.

Industry Benchmarks

IndustryTypical Gross Margin
SaaS70-85%
Fintech60-75%
E-commerce25-45%
Retail20-50%
Manufacturing25-35%
Restaurants60-70%
Consulting50-70%

Use benchmarks as reference points, not absolute targets. Your business model and strategy affect what margin is appropriate.

Common Gross Margin Mistakes

Mistake 1: Inconsistent COGS Definition

Different teams including different costs in COGS produces incomparable margins. Document exactly what's included and apply consistently.

Mistake 2: Missing Costs

Underreporting COGS overstates margin. Ensure all direct costs are captured - hosting, transaction fees, third-party tools, and direct labor.

Mistake 3: Including Operating Expenses

COGS includes only direct costs. Sales, marketing, R&D, and G&A are operating expenses - below the gross profit line.

Mistake 4: Timing Mismatches

Revenue and COGS should match in time. Revenue recognized this quarter should pair with costs from this quarter, not prior periods.

Mistake 5: Ignoring Volume Effects

Gross margin often changes with volume due to fixed costs within COGS. Understand how margin scales with revenue.

MetricWhat It Measures
Gross MarginRevenue retained after direct costs
Operating MarginRevenue retained after all operating expenses
Net MarginRevenue retained after all expenses including taxes
Contribution MarginRevenue minus variable costs only

Each margin level provides different insight into business profitability.

Improving Gross Margin

Pricing Strategies

  • Value-based pricing to capture more revenue
  • Reduce discounting
  • Implement tiered pricing

Cost Reduction

  • Negotiate better supplier terms
  • Optimize hosting and infrastructure
  • Automate manual processes

Mix Optimization

  • Shift sales toward higher-margin products
  • Reduce low-margin product offerings
  • Target higher-margin customer segments

Gross Margin in Context-Aware Analytics

metric:
  name: Gross Margin
  description: Revenue retained after cost of goods sold
  calculation: |
    (SUM(revenue) - SUM(cogs)) / SUM(revenue) * 100
  filters:
    - revenue_type = 'operating'
  dimensions: [product_line, customer_segment, region]
  cogs_includes:
    - hosting_costs
    - payment_processing
    - support_direct_costs
  owner: finance_team
  certified: true

With explicit COGS definitions, gross margin calculations are consistent across all reports and analyses - eliminating confusion about what costs are included.

Questions

Gross profit is a dollar amount (revenue minus cost of goods sold). Gross margin is a percentage (gross profit divided by revenue). Both measure the same underlying profitability but in different units - dollars vs. percentage.

Related