Excel guide · 3 min read
How to calculate profit margin in Excel
=(B2-C2)/B2, with price in B and cost in C, formatted as a percentage. A mug that sells for $18.00 and costs $7.20 has a 60% margin. Margin is always a share of the price, so it can never reach 100%; if you divide by cost instead, you are calculating markup.Sample data
Every result on this page was calculated from this sheet by the same spreadsheet engine the Cellwise app uses.
| A | B | C | D | E | F | G | H | I | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | Product | Price | Cost | Units sold | Line | Year | Target margin | ||
| 2 | Ceramic mug | 18 | 7.2 | 340 | Revenue | 184000 | 0.6 | ||
| 3 | Soy candle | 32 | 11.5 | 210 | Cost of goods sold | 71800 | |||
| 4 | Linen notebook | 12 | 6.3 | 520 | Operating expenses | 86500 | |||
| 5 | Canvas tote | 24 | 8.4 | 160 | |||||
| 6 | Art print | 45 | 13.5 | 75 |
Gross margin for one product
Subtract cost from price to get the profit per unit, then divide by price. The parentheses matter: without them Excel divides C2 by B2 first. Format the cell as Percentage (Home > Number > %).
The mug makes $10.80 on an $18.00 sale. $10.80 is 60% of the price.
Result: 0.6 shows as 60% with Percent format
0.6, which shows as 60% when formatted as a percentage.
Margin vs markup: the same mug, two numbers
Margin divides profit by price. Markup divides the same profit by cost. For the mug, $10.80 / $18.00 = 60% margin, while $10.80 / $7.20 = 150% markup. Both are correct; they answer different questions. Margin tells you how much of each sale you keep. Markup tells you how much you added on top of what you paid.
You can convert one to the other: margin = markup / (1 + markup), and markup = margin / (1 - margin). A 60% margin is a 150% markup.
Result: 1.5 shows as 150% with Percent format
1.5, the 150% markup on the same mug. Same profit, different base.
Overall margin across products (weight by units sold)
Averaging the five margin percentages gives every product equal weight, even though you sold 520 notebooks and only 75 art prints. Weight by what you actually sold: total profit divided by total revenue.
SUMPRODUCT multiplies units by profit per unit for each row, then divides by units times price. The low-margin notebook sells the most, so the real overall margin is lower than the simple average of the five margins, which is about 61.3%.
Result: 0.60085567598 shows as 60.1% with Percent format
About 0.601: 60.1% of all sales revenue is gross profit, below the 61.3% simple average.
Gross vs operating margin from a P&L
Gross margin only takes off the cost of goods sold. Operating margin also takes off running costs like rent, wages and software. Net margin goes further and also subtracts interest and taxes. Use the one that matches your question: gross margin for pricing a product, operating or net margin for how the business is doing.
With $184,000 revenue, $71,800 cost of goods and $86,500 operating expenses, gross margin is 61.0%, and operating margin is shown below.
Result: 0.13967391304 shows as 14.0% with Percent format
About 0.140: an operating margin of 14.0% after all running costs.
Price for a target margin
To hit a target margin, divide the cost by (1 - margin). A $7.20 mug at a 60% target margin needs a price of $18.00. The common mistake is cost x (1 + 60%), which gives $11.52, a markup of 60% and a margin of only 37.5%.
Result: 18
$7.20 / 0.4 = $18.00, which gives exactly a 60% margin.
Common mistakes
Dividing by cost and calling it margin
Profit / cost is markup. Margin always divides by price (revenue). Label your columns clearly, because 60% margin and 60% markup are very different prices.
Leaving out the parentheses
=B2-C2/B2 calculates C2/B2 first and returns 17.6. Write =(B2-C2)/B2.
Averaging margin percentages
AVERAGE of the margin column ignores volume. Use total profit / total revenue, with SUMPRODUCT if you have units sold.
#DIV/0! on products with no price yet
Wrap the formula: =IF(B2=0,"",(B2-C2)/B2), or use IFERROR if blanks are expected.
FAQ
What is the formula for profit margin percentage in Excel?
=(price-cost)/price, formatted as a percentage. If you already have profit and revenue, it is simply =profit/revenue.
What is the difference between margin and markup?
Margin is profit as a share of the selling price; markup is profit as a share of cost. A $7.20 item sold for $18.00 has a 60% margin and a 150% markup.
How do I calculate the selling price from cost and margin?
Use =cost/(1-margin). For a 40% margin on a $30 cost, =30/(1-40%) gives $50.
Can profit margin be over 100%?
No. Profit can never be larger than the price, so margin tops out just under 100%. Markup can be any size, which is one way to tell them apart.
How do I show a negative margin?
If cost is higher than price, the formula returns a negative percentage, which is correct: you lose money on each sale. Use conditional formatting to highlight negatives in red.
Functions used
SUMPRODUCTMultiply then addIFPicks a result from a testIFERRORFallback when a formula errorsAVERAGEMean of numbers
Related guides
- How to calculate markup in Excel
- How to calculate percentage in Excel
- How to calculate a discount price in Excel
- #DIV/0! error in Excel
- How to calculate sales commission in Excel
- Formulas for a monthly budget in Excel
Updated