Margin Calculator Formula

Understand the math behind the margin calculator. Each variable explained with a worked example.

Formulas Used

Profit

profit = selling_price - cost

Profit Margin

margin_percent = selling_price > 0 ? (selling_price - cost) / selling_price * 100 : 0

Markup

markup_percent = cost > 0 ? (selling_price - cost) / cost * 100 : 0

Variables

VariableDescriptionDefault
costCost(USD)45
selling_priceSelling Price(USD)75

How It Works

Profit Margin Formula

Margin% = (Selling Price - Cost) / Selling Price × 100

Markup% = (Selling Price - Cost) / Cost × 100

Worked Example

A product costs $45 and sells for $75.

cost = 45selling_price = 75
  1. 01Profit = $75 - $45 = $30
  2. 02Margin = $30 / $75 = 40%
  3. 03Markup = $30 / $45 = 66.7%

Ready to run the numbers?

Open Margin Calculator