Margin (calculation)
Learn how to calculate margin with simple formulas and worked examples for gross, net and operating profit.
October 2023 | Published by Xero
Published Monday 17 August 2026
Table of contents
Key takeaways
- Margin is profit expressed as a percentage of revenue, calculated by dividing profit by revenue and multiplying by 100.
- Gross profit margin uses revenue minus cost of goods sold, while net profit margin accounts for all expenses and taxes.
- Margin is based on the selling price, whereas markup is based on cost.
- A healthy margin depends on your industry and business model, so compare your figures with similar businesses.
What is margin?

How to calculate gross profit margin
Margin is profit divided by revenue, multiplied by 100, and expressed as a percentage. It shows how much of each ringgit you earn becomes profit after covering costs.
There are two main types of margin. Gross profit margin measures revenue after subtracting only the cost of goods sold. Net profit margin goes further, accounting for all operating expenses and taxes. Operating profit margin sits between the two, measuring profit after operating expenses but before interest and tax. Tracking these figures helps you measure your profitability over time.
How to calculate gross profit margin

How to calculate net profit margin
Gross profit margin shows the percentage of revenue remaining after you subtract the cost of goods sold. The formula is: gross profit margin = (revenue − cost of goods sold) ÷ revenue × 100.
Gross profit is simply revenue minus cost of goods sold. To calculate your gross profit margin, follow these steps:
- Start with your total revenue for the period.
- Subtract the cost of goods sold to find gross profit.
- Divide gross profit by revenue.
- Multiply by 100 to express as a percentage.
For example, if your revenue is RM20,000 and your cost of goods sold is RM8,000, your gross profit is RM12,000. Gross profit margin = (12,000 ÷ 20,000) × 100 = 60%. This means you keep 60 sen of every ringgit earned after covering direct production costs.
How to calculate net profit margin
Net profit margin reveals what percentage of revenue remains after all expenses and taxes. The formula is: net profit margin = net profit ÷ revenue × 100. Net profit is revenue minus all expenses and taxes (you can also calculate net profit before tax as revenue minus expenses).
Understanding cost of sales and other operating expenses helps you see where your money goes. Using the earlier example: from RM12,000 gross profit, subtract RM3,000 in operating expenses and RM1,000 in tax to get RM8,000 net profit. Net profit margin = (8,000 ÷ 20,000) × 100 = 40%.
What is operating profit margin?
Operating profit margin measures how efficiently your core business generates profit before interest and tax. The formula is: operating profit margin = operating profit ÷ revenue × 100. Operating profit is gross profit minus operating expenses.
Using the same figures: RM12,000 gross profit minus RM3,000 operating expenses = RM9,000 operating profit. Operating profit margin = (9,000 ÷ 20,000) × 100 = 45%. This metric helps you assess day-to-day operational efficiency without the influence of financing costs or tax obligations.
Margin vs markup
Margin and markup both measure profit, but they use different bases. Margin expresses profit as a percentage of the selling price. Markup expresses profit as a percentage of the cost. Confusing the two can lead to pricing errors.
Consider an item that costs RM60 and sells for RM100. The profit is RM40. Margin = (40 ÷ 100) × 100 = 40%. Markup = (40 ÷ 60) × 100 = 66.7%. For a deeper comparison, see margin vs markup.
How to work out a selling price from your target margin
If you know your target margin, you can work backwards to find the right selling price. The formula is: selling price = cost ÷ (1 − target margin).
For example, if an item costs RM60 and you want a 40% margin: selling price = 60 ÷ (1 − 0.40) = 60 ÷ 0.60 = RM100. This ensures you hit your profit goal without guessing.
What is a good profit margin?
There is no single benchmark for a good profit margin. What counts as healthy depends on your industry, business model, and region.
Higher-overhead sectors such as hospitality and grocery retail tend to run thinner margins. Software and professional services often achieve higher margins because their variable costs are lower. Reviewing industry benchmarks for gross profit margin can help you set realistic targets.
Compare your margins against similar businesses rather than a universal figure. Accounting software's financial reports make it easy to track your margin over time so you can spot trends and act on them.
See your margins clearly with Xero
Keeping a clear view of your profit margins helps you price confidently and plan for growth. Xero pulls your income and expenses into real-time reports, so you can monitor gross and net profit margins without manual calculations. You can get one month free and start tracking your margins from day one.
FAQs on calculating margin
Below are answers to common questions about calculating margin.
How do you calculate profit margin?
Divide your profit by revenue and multiply by 100. The type of profit you use (gross or net) determines which margin you calculate.
What is the difference between margin and markup?
Margin uses the selling price as the base; markup uses the cost. The same profit amount produces a higher markup percentage than margin percentage.
What is a good profit margin?
It varies by industry. Compare your margins to competitors and sector averages to judge whether your figures are healthy.
How do you work out a selling price from a target margin?
Divide your cost by (1 minus the target margin expressed as a decimal). For a 40% margin on a RM60 item, the selling price is RM100.
Related terms
Learn more about calculating margin
Handy resources
Advisor directory
You can search for experts in our advisor directory
Explore our guides
Find guides with expert advice and tools to help manage and grow your business
Financial reporting
Keep track of your performance with accounting reports
Disclaimer
This glossary is for small business owners. The definitions are written with their requirements in mind. More detailed definitions can be found in accounting textbooks or from an accounting professional. Xero does not provide accounting, tax, business or legal advice.