SpreadsheetFormulas
beginner

Calculate Profit Margin From Revenue and Cost

You know what each product costs and what it sells for, and you need the margin — what share of each sale is profit — to compare products or check pricing.

Quick formula
=(B2-A2)/B2
Sample input
1ProductCostRevenue
2Desk120200
3Chair4560
4Lamp1830
Result
1ProductMargin
2Desk40%
3Chair25%
4Lamp40%

Excel & Google Sheets

=(B2-A2)/B2

This formula works in both Excel and Google Sheets.

How it works

With cost in column A and revenue in column B, revenue minus cost is your profit, and dividing by revenue turns it into a margin — the fraction of each sale you keep. Format the cell as a percentage: a $200 sale with a $120 cost shows 40%, meaning 40 cents of every dollar is profit. The denominator is what makes it a margin: dividing by revenue answers "what share of the sale is profit," while dividing by cost answers a different question (markup). Margin can never exceed 100%, so if you see 150%, you've computed markup by mistake.

B2-A2
Profit: revenue minus cost. The parentheses make this happen first.
/B2
Divide by revenue — margin is profit as a share of the sale.

When to use it

Use margin to compare profitability across products, quote jobs, set pricing floors, or track gross margin month over month. It's the number investors and lenders expect when they ask about profitability.

Common mistakes

  • Confusing margin with markup.

    Margin divides by revenue: =(B2-A2)/B2. Markup divides by cost: =(B2-A2)/A2. A $120 cost sold at $200 is a 40% margin but a 67% markup — quoting one when someone expects the other misprices the deal.

  • Trying to hit a target margin by adding it as markup.

    Adding 40% to cost (=A2*1.4) does NOT give a 40% margin. To price for a target margin, divide: =A2/(1-0.4).

  • Revenue of zero returns #DIV/0!.

    Free samples or unsold items break the division. Guard it: =IF(B2=0,"",(B2-A2)/B2).

Did this formula help?

Engine-verified against the sample data aboveLast reviewed 2026-07-08