How do you calculate gross margin?
Gross margin = (revenue − COGS) / revenue × 100
Subtract cost of goods sold from revenue and you have gross profit; divide that by revenue and multiply by 100 and you have gross margin: the share of each sales dollar left after direct costs. Markup takes the same gross profit and divides by COGS instead. One transaction, two lenses: margin says how much of the price you kept, markup says how much you added on top of cost.
A higher margin leaves more room for operating costs and marketing, and more left over as profit. Benchmarks spread wide by industry: grocery and distribution often run 10–30%, ecommerce and retail 30–50%, software commonly 70–90%. Watch the trend more than the level. A falling margin usually means input costs are rising or discounts are creeping in, and comparing margin by product or customer shows where the profitable business actually lives.
If revenue lives in invoices and costs live in supplier spreadsheets, Ferra pulls both into one table and keeps a per-product margin column current as new rows land.
How the gross margin calculator works
Both inputs come off the same income statement: that's the only requirement. Enter revenue and COGS for the period and you get three numbers back: gross profit in dollars, gross margin as a percentage of revenue, and markup as a percentage of cost.
- Revenue
- Total sales for the period, net of refunds, returns, and discounts. Use the top line of your income statement: not bookings, not bank deposits.
- Cost of goods sold
- The direct costs of what you actually sold: materials, direct labor, freight-in, plus hosting or fulfillment when delivery depends on them. Rent, marketing, and admin salaries stay out. Those are operating expenses, not COGS.
Calculating gross margin
A quarter brings in $125,000 of revenue against $100,000 of COGS. Gross profit is 125,000 − 100,000 = $25,000. Gross margin is 25,000 ÷ 125,000 = 0.20, or 20%: twenty cents of every revenue dollar survive direct costs.
Markup flips the base: the same gross profit divided by cost, 25,000 ÷ 100,000 = 0.25, or 25%. A 25% markup on cost and a 20% margin on price describe the same transaction from opposite ends. Margin can never pass 100%. Markup can.
Divide gross profit by COGS and call the result margin, and you've quietly overstated profitability. That figure is markup, and it always runs higher. A 100% markup is only a 50% margin. Check the base every time: margin divides by revenue, markup divides by cost.
What is a good gross margin?
Software and other digital products commonly clear 70–80% or more, because each additional sale carries little direct cost. Retail, distribution, and grocery often live around 20–30%, and many service businesses land between, around 50–70%. Comparing your margin to a company running a different model tells you almost nothing.
A high margin is room: room to spend on marketing, product, and overhead and still turn a profit. A low margin means volume has to do the work and operations have to run tight. Your own trend is the comparison that pays: a margin drifting down across several quarters flags rising input costs or creeping discounts before either reaches net profit.
How to improve gross margin
Price up or cost down, gross margin has no other levers. Each tactic below pushes one side or the other.
- Raise prices
- Small increases fall straight through to gross profit when volume holds. Trial them on new customers or new SKUs before repricing the whole catalog.
- Renegotiate supplier costs
- Volume commitments, longer contracts, or a second source cut unit costs: margin rises and the customer never notices.
- Shift mix toward higher-margin products
- Promote, bundle, and position the items that keep the most of each dollar. Blended margin moves even when no individual price does.
- Cut waste and shrinkage
- Spoilage, rework, and inventory write-offs inflate COGS without producing a dollar of revenue. Tightening them cheapens the goods you actually sell.
- Trim discounting
- A discount cuts revenue while COGS stands still, so it hits margin harder than it looks. Set discount floors and track discount rates by rep or channel.







