How to calculate margin
Learn the margin formula, work out gross, operating and net margin, and set prices that protect your profit.
October 2023 | Published by Xero
Published Wednesday 30 September 2026
Table of contents
Key takeaways
- Margin is the percentage of revenue you keep as profit, worked out as (revenue − costs) ÷ revenue × 100
- Gross, operating and net profit margin each subtract a wider set of costs, so comparing them shows where your money goes
- Margin divides profit by price while markup divides it by cost, so a 40% margin equals a 66.7% markup
- A common rule of thumb treats a 5% net margin as low and 20% as high, but benchmarks vary by industry and country
What is margin?

How to calculate gross profit margin
Margin is the percentage of your revenue you keep as profit after paying your costs. If your warung sells a bowl of noodles for Rp10,000 and keeps Rp3,000 after costs, your margin is 30%.
Knowing how to calculate margin shows how well your business turns sales into profit. There are three main types, and each one subtracts a wider set of costs:
- Gross profit margin shows what's left after the direct costs of making or buying what you sell
- Operating profit margin also subtracts running costs such as rent and wages, but leaves out interest and tax
- Net profit margin subtracts every expense, including interest and tax

How to calculate net profit margin
Whether you run a café in Jakarta or a consultancy in Surabaya, tracking all three shows where your money goes and where you can improve. For a closer look at each measure, read this profit margin explainer.
Margin formula
Every margin calculation follows the same basic formula. Only the costs you subtract change.
Margin = (Revenue − Costs) ÷ Revenue × 100
Dividing by revenue tells you how much of each rupiah of sales you keep, so you can compare margins across months and business sizes. The Corporate Finance Institute uses the same revenue-based approach for gross, operating and net profit margin.
Because profit can't exceed revenue, margin tops out at 100%. If you divide by cost instead, you're calculating markup, which is a separate measure.
How to calculate gross profit margin
Gross profit margin shows how much revenue is left after covering the direct costs of what you sell. These direct costs are called cost of goods sold (COGS), and include raw materials, packaging and the wholesale price of stock you resell.
Gross profit margin = (Revenue − COGS) ÷ Revenue × 100
Follow these steps to calculate it:
- Add up your total revenue for the period.
- Add up your COGS for the same period.
- Subtract COGS from revenue to get your gross profit.
- Divide gross profit by revenue.
- Multiply by 100 to get a percentage.
Say your coffee shop in Bandung brought in Rp120 million in revenue last quarter. Coffee beans, milk, cups and food supplies cost Rp45 million.
Gross profit = Rp120 million − Rp45 million = Rp75 million
Gross profit margin = Rp75 million ÷ Rp120 million × 100 = 62.5%
So for every Rp100,000 of sales, you keep Rp62,500 after paying for the products you sold. That Rp62,500 then has to cover rent, wages and other running costs.
A shrinking gross margin often means supplier costs are rising or your prices need a review. Find out more about what gross profit margin tells you and how to lift it.
How to calculate operating profit margin
Operating profit margin shows how efficiently your day-to-day business runs, before interest and tax. It's useful for tracking performance over time without financing costs clouding the picture.
Operating profit margin = (Gross profit − Operating expenses) ÷ Revenue × 100
Operating expenses include rent, wages, utilities, marketing and insurance. Follow these steps to calculate the margin:
- Calculate your gross profit for the period.
- Add up your operating expenses for the same period.
- Subtract operating expenses from gross profit to get your operating profit.
- Divide operating profit by revenue.
- Multiply by 100 to get a percentage.
Back at the Bandung coffee shop, operating expenses for the quarter come to Rp50 million. That's Rp15 million in rent, Rp30 million in wages, and Rp5 million for utilities and insurance.
Operating profit = Rp75 million − Rp50 million = Rp25 million
Operating profit margin = Rp25 million ÷ Rp120 million × 100 = 20.8%
Because it leaves out interest and tax, operating margin gives you a fair comparison with businesses that borrow differently. It focuses on how well you run the business itself.
How to calculate net profit margin
Net profit margin shows the percentage of revenue left after every expense, including COGS, operating costs, interest and tax. It's your true bottom line.
Net profit margin = (Revenue − Total expenses) ÷ Revenue × 100
Follow these steps to work it out:
- Add up your total revenue for the period.
- Add up all your expenses, including COGS, operating costs, interest and tax.
- Subtract total expenses from revenue to get your net profit.
- Divide net profit by revenue.
- Multiply by 100 to get a percentage.
For the coffee shop, add Rp6 million in interest and tax to the Rp45 million COGS and Rp50 million operating expenses. Total expenses come to Rp101 million.
Net profit = Rp120 million − Rp101 million = Rp19 million
Net profit margin = Rp19 million ÷ Rp120 million × 100 = 15.8%
You keep about Rp15,800 of every Rp100,000 in sales once all costs are paid. It's the clearest view of what the business earns, so track it alongside other ways to measure profitability.
How to calculate a target margin
A target margin works the formula backwards: you start with the margin you want and find the price or revenue that delivers it. It's a quick way to set prices that protect your profit.
Follow these steps to find the price for a target margin:
- Work out the full cost of one unit, including materials and packaging.
- Choose your target margin and write it as a decimal, for example, 20% becomes 0.2.
- Subtract that decimal from 1.
- Divide your cost by the result, using Price = Cost ÷ (1 − target margin).
If a product costs you Rp80,000 and you want a 20% margin, the price is Rp80,000 ÷ 0.8 = Rp100,000. To check, Rp20,000 profit ÷ Rp100,000 price × 100 = 20%.
You can also work out the revenue you need for a profit goal. Revenue = Target profit ÷ Margin %, so a Rp30 million profit at a 15% net margin needs Rp200 million in revenue.
To test different prices quickly, plug your numbers into this free margin calculator.
Margin vs markup
Margin and markup both describe the profit on a sale, but they divide it by different numbers. Margin divides profit by the selling price, while markup divides it by cost.
Say you buy a product for Rp60,000 and sell it for Rp100,000, making Rp40,000 profit.
Margin = Rp40,000 ÷ Rp100,000 × 100 = 40%
Markup = Rp40,000 ÷ Rp60,000 × 100 = 66.7%
The profit in rupiah is the same, yet markup looks bigger because it uses the smaller base. If you add a 40% markup expecting a 40% margin, you'll earn less than you planned.
Use these common conversions to price with confidence:
- A 20% margin equals a 25% markup
- A 33.3% margin equals a 50% markup
- A 40% margin equals a 66.7% markup
- A 50% margin equals a 100% markup
For more worked examples, see the glossary entry comparing the two.
What is a good profit margin?
A good profit margin depends on your industry and how your business is set up. A 5% net margin can be healthy for a grocery store but thin for a software business.
As a US-focused rule of thumb, Brex's guide to profit margins treats a 5% net margin as low, 10% as healthy and 20% as high. Brex also notes that the right number varies widely by industry and business model.
For sector comparisons, NYU Stern professor Aswath Damodaran publishes net margins by industry. His January 2026 figures for US listed companies include:
- Total market at 9.74%
- General retail at 5.61%
- Grocery and food retail at 1.32%
- Restaurants at 9.37%
- Business and consumer services at 7.03%
- Engineering and construction at 5.94%
- Software at 25.49%
These are averages for US public companies, so Indonesian small business margins may look quite different. Treat them as rough reference points for your own planning.
So what does a 30% margin mean? You keep Rp30,000 of every Rp100,000 in revenue as profit, and Rp70,000 covers costs. To reach it, you'd need a markup of about 42.9% on cost.
For benchmarks that fit your sector in Indonesia, ask your accountant or industry association. Your own monthly trend matters too: a steady or rising margin shows your pricing and costs are on track.
How price, cost and discounts change your margin
Small changes to price, cost or discounts can move your margin more than you'd expect. Take a product that sells for Rp100,000 and costs Rp70,000, giving a 30% margin.
If your supplier raises the cost to Rp80,000 and you keep the price at Rp100,000, your margin drops to 20%. A Rp10,000 cost rise takes a third of your profit per unit.
If you offer a 10% discount instead, the price falls to Rp90,000 while cost stays at Rp70,000. Your margin becomes Rp20,000 ÷ Rp90,000 × 100 = 22.2%, and profit per unit falls by a third.
To earn the same total profit after that discount, you'd need to sell 50% more units. When costs rise, reset your price with the target margin formula, then use the markup calculator to find the matching markup.
Common margin calculation mistakes
Most margin errors come from using the wrong base or the wrong numbers. Check your calculation against these common slips:
- Dividing profit by cost instead of revenue, which gives you markup
- Mixing periods, such as monthly revenue with quarterly costs
- Leaving out hidden costs such as delivery fees, packaging, payment fees and wastage
- Including value-added tax (Pajak Pertambahan Nilai, PPN) in revenue, which inflates your sales
- Treating margin as cash flow, when late-paying customers can leave you short of cash despite a healthy profit
- Comparing different margin types, such as your gross margin against another business's net margin
A negative margin means your costs exceeded revenue for the period. For example, Rp1 million in revenue and Rp1.2 million in costs gives (Rp1 million − Rp1.2 million) ÷ Rp1 million × 100 = −20%.
A short negative spell can happen during a launch or a quiet season. If it continues, review your pricing and costs straight away.
How to improve your profit margins
Once you know your numbers, you can work on growing them. Here are practical ways to lift your margins, with more ideas in this guide to boosting profit.
Reduce your cost of goods sold
Your direct costs are often the quickest place to find savings. Negotiate better rates with suppliers, buy in bulk where storage allows, or look for alternative materials that keep quality high.
Every rupiah you save on COGS goes straight to your gross profit.
Review your pricing
Prices set a year ago may not cover today's costs. Check what competitors charge, factor in your costs, and adjust prices to reflect the value you deliver.
A small increase goes a long way. Raising prices by 5% on a product with a 10% margin lifts your profit by 50%, as long as sales volume holds.
For example, a Rp100,000 product costing Rp90,000 earns Rp10,000. At Rp105,000, the same product earns Rp15,000.
Cut unnecessary expenses
Go through your operating expenses line by line. Cancel subscriptions you don't use and renegotiate contracts for internet, insurance or office supplies.
Small savings across several costs soon add up.
Upsell and cross-sell
Selling more to existing customers adds revenue without the cost of winning them. A coffee shop could offer a pastry with every coffee or a larger cup for a little extra.
Use accounting software to track margins
Margins are easier to improve when you can see them change. Accounting software keeps your sales and costs up to date, so you can spot a slipping margin early and act fast.
Track your margins with Xero
Once you know how to calculate each margin, regular tracking helps you price with confidence and keep costs in check. Xero's reporting features turn your accounting data into easy-to-read profit and loss reports, so you can compare margins month to month. Choose a plan and get one month free to see exactly where your profit comes from.
FAQs on calculating margin
Here are quick answers to common questions about calculating margin.
Is a 20% margin the same as a 25% markup?
Yes, both describe the same sale from different bases. A product costing Rp80,000 and selling for Rp100,000 makes Rp20,000 profit, which is 20% of the price and 25% of the cost.
Does PPN affect profit margin calculations?
Use PPN-exclusive figures, because the PPN you collect isn't your revenue and a taxable entrepreneur (Pengusaha Kena Pajak, PKP) credits input tax against output tax, as the Directorate General of Taxes explains. According to PwC's Indonesia tax summary, PPN is 12%, but a tax base of 11/12 gives most non-luxury goods and services an effective 11% rate.
How often should you calculate your margin?
Check it monthly when you review your profit and loss statement, and weekly while you're testing new prices. Comparing the same month year on year helps you separate seasonal dips from lasting changes.
What's the difference between gross and net profit margin?
Gross margin subtracts only COGS, while net margin subtracts every expense, including interest and tax. A healthy gross margin paired with a thin net margin often points to high overheads rather than pricing.
Can margin be higher than 100%?
Margin stays at or below 100% because profit can't exceed revenue, while markup has no ceiling. A product that costs Rp30,000 and sells for Rp100,000 has a 70% margin but a 233.3% markup.
Related terms
Learn more about how to calculate 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.