How to calculate profit margin (formula and examples)

- What is profit margin?
- Profit margin formula
- Types of profit margins
- How to calculate a target profit margin
- What is the difference between margin and markup?
- How to calculate profit margin percentage in Excel
- What is a good profit margin?
- How to improve your profit margin
- Track profit margins in real time with Ramp

Profit margin shows how much of your revenue you keep as profit after covering costs. Calculating profit margin helps you understand pricing, cost control, and overall business performance. Once you know your margin, you can compare results across time, benchmark against peers, and spot where profitability is slipping.
What is profit margin?
Profit margin is the percentage of your revenue that remains after subtracting costs. It shows how efficiently you turn sales into profit and is a core metric for pricing, planning, and performance tracking.
You track profit margins to:
- Compare performance over time
- Benchmark against competitors
- Identify where cost control or pricing improvements are needed
Tracking margin consistently helps you catch problems early, whether that's rising input costs, pricing that hasn't kept up with inflation, or operating expenses growing faster than revenue. A solid profitability analysis gives you the framework to act on what the numbers reveal.
Profit margin formula
To calculate profit margin, subtract your costs from revenue to find your profit, then divide that profit by revenue and multiply by 100 to get a percentage.
Here's the formula:
Profit margin (%) = (Net income / Revenue) * 100
Here's how to calculate it step by step:
- Find your total revenue for the period you want to measure
- Subtract all expenses (COGS, operating expenses, interest, and taxes) to get net income
- Divide net income by revenue to get a decimal
- Multiply by 100 to convert the decimal to a percentage
For example, say your business generates $500,000 in revenue and has $450,000 in total expenses:
- Net income = $500,000 – $450,000 = $50,000
- Profit margin = ($50,000 / $500,000) * 100 = 10%
That means you keep 10 cents of every dollar in revenue as profit.
Types of profit margins
There are different ways to calculate profit margin depending on which costs you include. Each type answers a different question about your profitability.
Gross profit margin
Gross profit margin measures how much of your revenue remains after subtracting the cost of goods sold (COGS), such as materials and direct labor. It shows how efficiently you produce or deliver your product or service.
Gross profit margin = (Revenue – COGS) / Revenue * 100
Use gross profit margin to evaluate pricing, sourcing, and production efficiency before accounting for overhead or administrative costs. If your revenue is $500,000 and COGS is $300,000, your gross profit margin is 40%.
Operating profit margin
Operating profit margin goes a step further by subtracting operating expenses, such as salaries, rent, and marketing, from gross profit. It reflects how well you manage day-to-day business costs but excludes interest and taxes.
Operating profit margin = Operating income / Revenue * 100
Service-based businesses often report stronger operating margins, while capital-intensive industries like manufacturing and logistics tend to operate with tighter margins due to higher overhead.
Net profit margin
Net profit margin is the bottom-line profitability metric. It shows what you keep after every expense, including COGS, operating costs, interest, taxes, and one-time charges.
Net profit margin = Net income / Revenue * 100
Because it captures every cost, net profit margin is the most comprehensive view of how profitable your business actually is.
| Margin type | What it includes | What it measures |
|---|---|---|
| Gross | COGS only | Production efficiency |
| Operating | COGS + operating expenses | Operational efficiency |
| Net | All expenses | Overall profitability |
How to calculate a target profit margin
To hit a target profit margin, work backward from cost using Price = Cost / (1 − target margin), rather than guessing at a markup and hoping the math works out.
Say a product costs you $60 to make. For a 20% margin, divide $60 by 0.80 to get a selling price of $75. For a 30% margin, divide $60 by 0.70 to get $85.71.
Here's how the required price shifts as your target margin climbs, using that same $60 cost:
| Target margin | Required price (cost = $60) |
|---|---|
| 10% | $66.67 |
| 20% | $75.00 |
| 30% | $85.71 |
| 40% | $100.00 |
| 50% | $120.00 |
Once you've set a target price, test it against real demand before rolling it out.
What is the difference between margin and markup?
Margin and markup describe the same dollar of profit but from different angles. Margin is profit as a percentage of the selling price, while markup is profit as a percentage of cost. Confusing the two leads to pricing mistakes.
Take a product that costs you $60 to make and sells for $100:
- Margin = ($100 – $60) / $100 * 100 = 40%
- Markup = ($100 – $60) / $60 * 100 = 66.7%
Same $40 in profit, two very different percentages. Markup always looks larger because it's calculated against a smaller base.
When to use margin
Use margin for financial reporting, comparing profitability across products or time periods, and analyzing how much of each sale becomes profit. It's the right metric when you're evaluating overall business performance.
When to use markup
Use markup when you're setting prices. It's the practical lever for figuring out what to charge based on your cost and the profit you want to earn on each unit sold.
How to calculate profit margin percentage in Excel
Excel makes it easy to calculate margin once you know the formula. The basic formula is:
=(Revenue Cell–Cost Cell)/Revenue Cell
Then format the cell as a percentage. Here's how to build a simple margin calculator in four steps:
- Step 1: Enter your revenue in one cell (for example, B2)
- Step 2: Enter your total costs in another cell (for example, B3)
- Step 3: In a third cell, enter the formula =(B2–B3)/B2
- Step 4: Format that cell as a percentage
| Cell | Contents | Example value |
|---|---|---|
| B2 | Revenue | $500,000 |
| B3 | Cost | $450,000 |
| B4 | =(B2-B3)/B2 | 10% |
You can build a matching required-price calculator with the target-margin formula: =Cost/(1–TargetMargin). For a $60 cost and a 30% target margin, that's =B3/(1–0.3), which returns $85.71.
From there, you can link the spreadsheet to accounting exports so revenue and expense data update automatically. That keeps margin calculations accurate as the numbers change.
What is a good profit margin?
A good profit margin depends on your industry, business model, and growth stage, so a generic benchmark can be misleading. The better question is whether your margin is improving over time and how it stacks up against peers in your sector, which you can assess through a profitability analysis.
Good profit margins by industry
Here's how typical net profit margins compare by industry:
| Industry | Typical net profit margin | Note |
|---|---|---|
| Software/SaaS | 26% | Low cost to deliver each additional unit |
| Retail (general) | 6% | Thin margins from inventory and price competition |
| Restaurants | 9% | Squeezed by food cost and labor |
| Construction | 11% | Driven by project risk and bidding |
| Transportation | 8% | High fixed costs from fleets and fuel |
Context and trend beat any universal number. A 10% margin can be excellent in one industry and a warning sign in another.
How to improve your profit margin
Calculating margin is just the starting point. Improving it comes from a mix of better data, smarter pricing, and tighter cost control, not blanket cost cutting.
Track income and expenses consistently
You can't improve what you don't measure. Consistent expense tracking is the foundation for any margin improvement effort because it shows you exactly where revenue is going.
Inconsistent categorization, missing receipts, and delayed reporting all distort your margin numbers. Clean, current data lets you spot cost creep before it eats into profitability.
With Ramp's Accounting Agent, businesses see 70% fewer coding corrections within the first month as the agent learns from feedback, so your margin calculations rest on accurate data instead of manual spreadsheet cleanup.
Automate financial processes
Manual processes waste time and introduce errors that compound over the course of a year. Ramp's Accounting Agent auto-codes every transaction the moment it posts, across GL, department, class, and location, with no rules to build or maintain.
That drives a 3x faster monthly close and 3.5x more transactions auto-coded than rules-only tools, and every AI decision carries a confidence level, rationale, and override option, so you get speed without losing the audit trail. Pairing that with ERP automation can further reduce the manual handoffs that slow down reporting.
Reduce operating costs
Review recurring expenses regularly to find savings that don't hurt output. Renegotiating supplier contracts, eliminating redundant software, and consolidating tools can all trim overhead.
Pay close attention to underused subscriptions and shadow IT spending. These quietly drain margins without anyone noticing until you do a full audit.
Optimize your pricing strategy
Use margin calculations to make sure your pricing covers costs and delivers the profitability you need. If you have a target margin in mind, you can reverse-engineer the right price using this formula:
Price = Cost / (1 – Target margin)
For example, if a product costs $60 and you want a 40% margin, divide $60 by 0.60 to get a selling price of $100. Test price changes gradually to balance margin gains against any impact on demand.
Track profit margins in real time with Ramp
Calculating profit margins accurately requires clean expense data, but manual categorization and scattered receipts create opportunities for error. Ramp's accounting automation software eliminates the guesswork by coding every transaction automatically, collecting receipts in real time, and syncing everything to your ERP so you always know where your money goes.
Ramp's Accounting Agent learns your chart of accounts and applies the right GL codes, departments, classes, and locations to every expense as it posts. You get complete visibility into cost centers and spending patterns without chasing down receipts or fixing miscoded transactions after the fact. When expenses land in the right categories from day one, you can calculate margins with confidence and spot trends before they impact profitability.
Here's how Ramp helps you track and improve margins:
- AI-powered coding: Ramp codes transactions across all required fields in real time, so expenses are categorized correctly and margins reflect actual costs
- Automated receipt collection: Ramp texts employees for missing receipts and matches them to transactions automatically, eliminating the manual work that slows down reporting
- Real-time spend visibility: Track expenses by department, project, or cost center as they happen, so you can identify margin erosion early and adjust spending before it's too late
- Seamless ERP sync: Ramp syncs coded transactions to your accounting system automatically, so financial reports are always current and margin calculations are based on complete data
Try a demo to see how Ramp gives you the clean expense data you need to calculate and improve profit margins.

FAQs
Divide your cost by 0.80 (1 minus 0.20) to find the selling price needed to hit a 20% margin. A product that costs $40 would need to sell for $50 ($40 / 0.80) to deliver a 20% margin.
Divide your cost by 0.70 (1 minus 0.30) to find the required selling price. A product that costs $70 would need to sell for $100 ($70 / 0.70) to hit a 30% margin.
The profit margin ratio is net income divided by revenue, expressed as a decimal or percentage. It's the same calculation as net profit margin and is one of the most common profitability ratios used in financial analysis.
Subtract the cost from the selling price to find your profit, then divide that profit by the selling price and multiply by 100. If you sell something for $200 that cost $150, your margin is ($200 – $150) / $200 * 100 = 25%.
Not necessarily. Very high margins can signal underinvestment in growth or product development, while lower margins can be sustainable in high-volume businesses like grocery or e-commerce, so context and industry benchmarks matter more than the raw number.
“I assumed I would have to choose between speed and control. What I found is that you can have both. A well-designed system takes friction out, for the finance function and for everyone else.”
Justin Webster
CFO, Denver Broncos

“A well-run district should not have to choose between getting work done at the school site and keeping control of the dollars behind it. We're not hiring more people to do more jobs, so we have to be smarter about the process. With Ramp, the purchase, the receipt, and the record stay together from the start. ”
Nick Brizeno
Director of Purchasing, San Marcos Unified School District

“In senior living, scale only works if the communities still feel personal. We needed the back office to carry more of the complexity, not the people serving residents. Ramp helped us build that infrastructure, so the experience in the community could stay human.”
Ryan Cole
CFO, Agemark Senior Living

“AI is moving faster than the finance context around it. Prices change, models change, and the value is not always obvious from an invoice. We needed enough detail to know which bets deserved more investment — and which ones did not.”
Greg Cooley
Controller, AngelList

“Invoices, cards, tokens. The categories change but the principle doesn't: know where the money is going, remove the work around it, and make sure the spend is worth it.”
Maciej Mylik. Finance
ElevenLabs

“We weren’t trying to retrofit an old finance system. We had a blank canvas, and Ramp gave us the foundation to build a global finance function of the future.”
Justin Dourado
Director of Finance, Othership

“There's just no surprises anymore. No more waiting two months to find out how a job did. We know how it's doing as it's happening.”
Erich Kuss
Financial Systems Manager, Infinity Home Services

“More token spend isn’t proof that AI is working. Less isn’t proof that it isn’t. What matters is whether we’re buying the right level of intelligence for the work. Ramp lets us make that judgment in the same place we manage every other type of spend.”
Cody Nutt
Senior Director of Business Systems, Daxko



