Profit margins: gross, operating, net and EBITDA in DAX

How to calculate gross margin, contribution margin, operating margin, EBITDA margin and net margin, from a profit and loss statement in a worked example, margin against markup, the DAX on a general ledger with account mapping, margin by product and customer, and the mistake of averaging margins.

Short answer: a margin is a profit divided by revenue. Gross margin = (revenue - cost of goods sold) / revenue. Contribution margin also takes off other variable costs (shipping, payment fees). Operating margin = operating profit (EBIT) / revenue, after all operating costs. EBITDA margin adds back depreciation and amortisation. Net margin = net profit after interest and tax / revenue. In DAX, compute each as DIVIDE ( profit, revenue ) on totals, never as an average of line margins.

Each margin answers a different question: gross margin, "do our products make money?"; operating margin, "does the business?"; net margin, "what is left for the owners?".

How do the margins come from a P&L?

LineAmountMargin
Revenue10,000100%
Cost of goods sold-6,000
Gross profit4,00040.0%
Variable selling costs (shipping, fees)-800
Contribution3,20032.0%
Operating expenses (staff, rent, marketing)-1,900
EBITDA1,30013.0%
Depreciation and amortisation-300
Operating profit (EBIT)1,00010.0%
Interest-100
Tax-225
Net profit6756.75%
A profit and loss statement (k)
02,0004,0006,0008,00010K10KRevenue-6,000Cost of goods sold-800Variable costs-1,900Operating expenses-300Depreciation-325Interest and tax675Net profit
From revenue to net profit (k)

Margin or markup?

Margin divides profit by revenue; markup divides it by cost. A product bought for 60 and sold for 100 has a 40% margin and a 66.7% markup. Price lists often use markup, finance uses margin; label which one a report shows.

What is the DAX?

On a general ledger table (Account, Date, Amount) with an account mapping table (Account, P&L Line, Sign):

Amount = SUM ( GL[Amount] )

Revenue = CALCULATE ( [Amount], Accounts[P&L Line] = "Revenue" )
COGS = CALCULATE ( [Amount], Accounts[P&L Line] = "COGS" )
Variable Costs = CALCULATE ( [Amount], Accounts[P&L Line] = "Variable costs" )
Opex = CALCULATE ( [Amount], Accounts[P&L Line] = "Opex" )
D&A = CALCULATE ( [Amount], Accounts[P&L Line] = "D&A" )
Interest and Tax = CALCULATE ( [Amount], Accounts[P&L Line] IN { "Interest", "Tax" } )

-- costs stored as positive amounts
Gross Profit = [Revenue] - [COGS]
Contribution = [Gross Profit] - [Variable Costs]
EBITDA = [Contribution] - [Opex]
EBIT = [EBITDA] - [D&A]
Net Profit = [EBIT] - [Interest and Tax]

Gross Margin % = DIVIDE ( [Gross Profit], [Revenue] )
Contribution Margin % = DIVIDE ( [Contribution], [Revenue] )
EBITDA Margin % = DIVIDE ( [EBITDA], [Revenue] )
Operating Margin % = DIVIDE ( [EBIT], [Revenue] )
Net Margin % = DIVIDE ( [Net Profit], [Revenue] )

Sign conventions differ between ledgers (revenue often negative, costs positive); fix them once in the mapping table's Sign column, SUMX ( GL, GL[Amount] * RELATED ( Accounts[Sign] ) ), rather than in each measure.

How do you show margin by product or customer?

Gross and contribution margins can be calculated per product or customer from sales lines with cost. Operating costs are usually not assigned per product, so operating and net margins stay at company or business-unit level, unless you allocate costs with an agreed key.

020406058Accessories46Clothing31Bikes22Components
Gross margin % by product category

Sort by margin and show revenue next to it: a low-margin category can still bring most of the gross profit.

What goes wrong?

  • Averaging margin percentages. The margin of a total is total profit / total revenue; AVERAGE of line margins weights a 1-euro sale like a 10,000-euro one.
  • Margin against markup. Mixing them makes 40% and 67% look like different businesses.
  • Costs missing from the sales table. Gross margin needs the cost at the time of sale; today's standard cost rewrites history.
  • Sign mix-ups. One wrong sign turns a cost into income; check totals against the official P&L.

Where can you check this?

Where do you start?

Map your ledger accounts to P&L lines once, then build the five profit measures and their margins. Budget variance compares them with plan.

Keep reading

More from the blog.

Every post

Next

Building this? Say hello.

A question about this post, a pattern you would build differently, or the next thing you want written out: Behnia reads every message.