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?
| Line | Amount | Margin |
|---|---|---|
| Revenue | 10,000 | 100% |
| Cost of goods sold | -6,000 | |
| Gross profit | 4,000 | 40.0% |
| Variable selling costs (shipping, fees) | -800 | |
| Contribution | 3,200 | 32.0% |
| Operating expenses (staff, rent, marketing) | -1,900 | |
| EBITDA | 1,300 | 13.0% |
| Depreciation and amortisation | -300 | |
| Operating profit (EBIT) | 1,000 | 10.0% |
| Interest | -100 | |
| Tax | -225 | |
| Net profit | 675 | 6.75% |
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.
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;
AVERAGEof 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?
- Microsoft Learn: DIVIDE function (DAX)
- Microsoft Learn: Waterfall charts in Power BI
- Microsoft Learn: RELATED function (DAX)
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.