Asset 20 8 2
Does AI recommend your business? Run the free check →

Join 15,000 business owners, marketers and entrepreneurs. The Sunday newsletter you'll be annoyed only arrives once a week.

Article

How to Calculate Gross Margin: The Formula and a Worked Example

To calculate gross margin, subtract the cost of goods sold (COGS) from net sales, divide the result by net sales and multiply by 100. The answer is the percentage of each sale you keep after paying the direct cost of what you sold.

Shopify writes the formula as gross margin = ((net sales - COGS) / net sales) x 100, and CFI writes the same ratio as (revenue - COGS) / revenue. Shopify's Q4 2025 survey found 42% of merchants cite ensuring profitability as their top business goal, and gross margin helps explain why profit comes in higher or lower than expected. The dollar figures below are the sources' own examples, as of October 2026.

The two numbers you need

Net sales are your gross sales after deducting returns, allowances and discounts. COGS is the direct cost of producing or buying the goods you sold in the period. You'll find both on your profit and loss statement, which is also called an income statement. If you don't have one yet, start with this profit and loss statement template.

Getting COGS right is where most calculations go wrong. Shopify lists what belongs in it and what doesn't, while noting that exact classifications vary by business and accounting method:

Counts as COGSDoesn't count as COGS
Wholesale product costsMarketing costs
Raw materialsAdministrative salaries
Direct production labourOffice rent and utilities
Inbound freight and import dutiesInterest payments
Packaging needed to prepare products for saleIncome taxes

Worked example: a dishware company's quarter

Shopify's example is a dishware company with $27,000 in net sales for the quarter and $10,000 in COGS:

  1. Find gross profit: $27,000 - $10,000 = $17,000.
  2. Divide gross profit by net sales: $17,000 / $27,000 = 0.6296.
  3. Multiply by 100: 0.6296 x 100 = 62.96%.
  4. Round it: a gross margin of about 63%.

In plain terms, 63 cents of every dollar of net sales is left after paying for the dishes themselves. That 63 cents has to cover everything else the business spends, and whatever remains is profit.

A second check with CFI's numbers

CFI runs the same ratio on a sample income statement with revenue of 102,007 and COGS of 39,023:

  1. Subtract COGS from revenue: 102,007 - 39,023 = 62,984.
  2. Divide by revenue: 62,984 / 102,007 = 0.6174.
  3. Multiply by 100: a gross margin of 61.74%.

CFI reads that as $0.3826 of every dollar going to COGS and $0.6174 left over for expenses, taxes and the rest. Its simpler illustration: at a 20% gross margin, you keep $0.20 of each dollar and $0.80 goes to COGS.

In a spreadsheet, put net sales in one cell and COGS in the next, then divide the difference by net sales and format the result as a percentage. Do it per product as well as for the whole business, because a strong overall figure can hide one product that barely covers its own cost.

What your gross margin tells you

Gross profit and gross margin come from the same figures. Shopify's distinction is that gross profit is a currency amount and gross margin is a percentage of net sales, which is what makes products or periods with different sales totals comparable. That comparison is where the number earns its keep:

  • Growth can hide a problem. Shopify's example: quarterly gross profit rises from $100,000 to $120,000 while gross margin falls from 40% to 32%. More sales, but each sale became less profitable, usually from rising product costs or heavier discounting.
  • It prices your growth plans. At a 40% gross margin, an extra $10,000 in net sales brings in about $4,000 of gross profit, if costs and sales mix stay similar. Compare that with what it would cost to win those sales.
  • Small moves add up. At $1 million in net sales, raising gross margin from 40% to 41% adds $10,000 in gross profit.

Gross margin only covers COGS. Shopify's illustration is a retailer with a 63% gross margin and a 10% net margin once every other expense is paid. I've set out that difference in currency terms in gross profit vs net profit, and if you price by adding a percentage to cost, read markup vs margin before you set any targets, because the two percentages aren't interchangeable.

Work with me

Want AI doing the heavy lifting in your marketing?

I build the systems that handle the boring 80 percent, so you get your week back. Done properly, with the human kept in.

Is your gross margin good? Compare within your industry

CFI says a low gross margin doesn't necessarily mean a company is performing badly. Compare businesses in the same industry, not across industries. A legal services firm has a high ratio because its production costs are low, while a car manufacturer's is lower because its production costs are high. CFI's numbers make the point: McDonald's had a gross margin of 41.4% at the end of 2016 and Bank of America 97.8%, and comparing the two tells you nothing useful.

Shopify quotes NYU Stern's January 2026 averages for US public companies:

IndustryAverage gross margin
Retail (grocery and food)26.31%
Retail distributors30.57%
General retail33.18%
Specialty retail35.3%
Apparel56.88%

Public companies buy and operate at a different scale from a small online shop, so treat these as context, not a target. A better target comes from your own costs. Shopify's example: if operating expenses are 25% of sales and you want a 10% operating margin, you need a gross margin of at least 35%.

The two levers that move it

CFI and Shopify agree that most improvements come from two places: raising prices or lowering COGS. Buying inventory more cheaply, through purchase discounts or a less expensive supplier, lifts the ratio. So does charging more, though CFI warns it has to stay competitive or fewer customers will buy. Shopify adds two more: shift your sales mix towards higher-margin products, and set a minimum acceptable margin before you run any discount.

My take

Use gross margin to decide what to charge and where to buy. Work it out per product, not just for the whole business, and check it every quarter. If gross profit is growing but the percentage is slipping, stop and find out why before you spend more chasing sales.

Frequently asked questions

What is the formula for gross margin?

Gross margin = (net sales - COGS) / net sales x 100. CFI writes the same ratio as (revenue - COGS) / revenue.

What is an example of a gross margin calculation?

In Shopify's example, $27,000 in net sales minus $10,000 in COGS leaves $17,000 of gross profit. $17,000 divided by $27,000 is 0.6296, or a gross margin of about 63%.

What is included in COGS?

Shopify lists wholesale product costs, raw materials, direct production labour, inbound freight and import duties, and packaging needed to prepare products for sale.

What is a good gross margin?

It depends on your industry. CFI says to compare companies in the same industry, and NYU Stern's January 2026 averages range from 26.31% for grocery retail to 56.88% for apparel.

Published and maintained by the Lilach Bullock team, covering marketing, AI and business growth.
Your buyers are asking AI who to use. Does it say you?

See for free whether ChatGPT, Claude, Perplexity, Gemini and Google name you, and get the plan to become the answer.

Check my AI visibility →
Sundays only

Get the Sunday newsletter.

One email a week. AI experiments, marketing tactics, and the workflows Lilach is building right now in her own business.

Subscribe free

Let’s get your marketing running on AI.

Book a free 30-minute call

We figure out what you need, where AI fits in, and what working together would look like.

Book the call →

Or take the 30-second calculator

You’ll see the hours and the money quietly leaking out of your week, and the three workflows worth building first.

Take the calculator →

Or grab the free AI resource library

Prompt packs, templates, checklists, and swipe files. The exact tools I build for paying clients. Yours, free.

Get the library →
Keep reading

More from the blog.