By Michael Nocito , data analyst · Published August 11, 2026 By the end of this page you can look at an income statement and say, in one sentence, which layer of the business is losing the money. You will know what each of the three margins measures, why they always step down in order, the SQL that computes all three in one pass, and the two ways that SQL quietly returns the wrong number. Try this before you read another word. Take any two periods of your company's numbers. Work out what percent revenue grew, then what percent profit grew. If profit grew slower, the business got bigger and kept less of each dollar, and the three margins tell you which layer ate the difference. In one line: a margin is a profit line divided by revenue. Each one subtracts one more layer of cost, so gross is always at least operating, and operating is always at least net. The stepping-down is the whole shape of it, so it gets the picture. The original carries a diagram here. In words: A single horizontal bar representing one dollar of revenue, drawn four times, one row under the next, each row shorter than the one above it. The top row is the full bar, labeled revenue, running the whole width. The second row is 60 percent as long and labeled gross; the piece missing from its right-hand end is drawn as a hatched block labeled cost of goods. The third row is 22 percent as long and labeled operating; the piece missing from the second row is a hatched block labeled operating expense. The fourth row is 14 percent as long and labeled net; the piece missing from the third row is a hatched block labeled interest and tax. Each hatched block sits directly to the right of the bar it was taken from, so the four rows form a descending staircase with the removed costs stacking to the right. A dashed vertical line marks the left edge shared by every bar, showing that all four are measured from the same starting point, which is revenue. The picture is the reason the three margins can never cross: each one starts from the row above it and can only get shorter. Every number on this page is verified, and you can check them. The worked example is one small company's two most recent years, shown in full below. Every margin, growth rate, subtotal and monthly figure was computed in SQLite and cross-checked in pandas before it went on the page, so you can check any cell by hand and it will agree. 1. What a margin is, and why divide by revenue at all Two years of profit, 560,000. Say whether that company had a good year, and say what you would need to know to be sure. A margin is a profit line divided by revenue, written as a percent. That is the entire definition. If revenue is 560,000, the net margin is 560,000 divided by 4,000,000, which is 0.14, which is 14%. The reason to divide is that raw profit dollars cannot be compared to anything. A bigger year makes more profit almost automatically, so "profit went up" tells you the company got bigger, not that it got better. Dividing by revenue converts the number into cents kept per sales dollar, and cents kept per dollar can be compared to last year, to the plan, and to a competitor ten times the size. One warning about the word "kept," because it is doing less work than it sounds like. A margin of 14% does not mean 14 cents of every dollar is in the bank. It means 14 cents survived on paper, and paper and cash part company constantly. A customer who has not paid yet still counts as revenue and still counts as profit. A company can post its best margin ever and miss payroll in the same month. What a business can actually pay is a different question with different arithmetic, and it lives on the balance sheet rather than here: the current ratio and the quick ratio are the two numbers that answer it. Here is the same idea in one line you can hold on to. Profit answers "how much did we make." A margin answers "how much of what came in did we keep, on paper." Those are different questions, and only the second one survives a change in size. 2. The three margins, and the layer each one accuses If a company's product sells profitably but the company loses money overall, which of the three margins would still look healthy? An income statement is a cascade. Revenue at the top, then costs subtract in layers, and each subtotal along the way is a profit line worth dividing by revenue. Three of those subtotals matter most. Gross margin is gross profit divided by revenue, where gross profit is revenue minus cost of goods sold. Cost of goods sold is what it costs to make or deliver the thing you sold: materials, the people who build it, shipping. Gross margin is the product's own economics. It moves when you change your price or when your suppliers change theirs, and almost nothing else touches it. Operating margin is operating income divided by revenue, where operating income is gross profit minus operating expense. Operating expense is the cost of running the company rather than making the product: sales salaries, rent, software, marketing, the finance team. Operating margin is the core business. It moves when overhead grows faster than sales. Net margin is net income divided by revenue, and net income is what is left after everything, including interest on borrowed money and tax. Net margin moves on how much debt the company carries and what it pays the government, neither of which has much to do with how well the product sells. So each margin removes one more layer, and that is why they always fall in the same order: gross is at least operating, and operating is at least net. When a company's product is profitable but the company is not, gross margin stays healthy and the collapse shows up below it. The margin that stops looking good is the layer that owes you an explanation. 3. The worked income statement, two years side by side Revenue is about to grow by a third. Guess whether net margin goes up or down, and write your guess down. Here is the company. It sells coffee equipment, it books everything in whole dollars, and these are its last two fiscal years. Line 2023 2024 Revenue 3,000,000 4,000,000 Cost of goods sold 1,110,000 1,600,000 Gross profit 1,890,000 2,400,000 Operating expense 1,116,000 1,520,000 Operating income 774,000 880,000 Interest 60,000 120,000 Tax 176,000 200,000 Net income 538,000 560,000 Check one column by hand to trust the rest. 2024: 4,000,000 minus 1,600,000 is 2,400,000 gross profit. Minus 1,520,000 of operating expense is 880,000. Minus 120,000 of interest and 200,000 of tax is 560,000. Now the same two years as margins. Margin 2023 2024 Change Gross 63.0% 60.0% -3.0 points Operating 25.8% 22.0% -3.8 points Net 17.9% 14.0% -3.9 points Both tables describe the same two years. The first one says the company had its best year. The second one says the company had its worst year in a while. Revenue grew 33.3%, gross profit grew 27.0%, operating income grew 13.7%, and net income grew 4.1%. Every line went up, and every line went up slower than the one above it. The one sentence this table earns: the company grew a third bigger and now keeps 14.0 cents of every dollar instead of 17.9. Put the shortfall in dollars and it stops being abstract. At last year's net margin, 717,333 of net income. It produced 157,333, which is more than a quarter of the profit the company actually made. Say why net margin can fall while net income rises, in your own words, before reading on. If you can say it, the rest of this page is arithmetic. 4. The query, and the division that returns 0 In SQL, 2400000 / 4000000 where both columns are whole numbers. What comes back? Zero. Not 0.6. Most databases follow the rule that a whole number divided by a whole number is a whole number, so the 0.6 is thrown away and you get 0. Multiply that 0 by 100 afterwards and you get 0. The query runs, the column fills with zeros, and nothing anywhere says an error happened. The fix is to make one side of the division a decimal, and to do it before the division rather than after. Writing 100.0 * at the front of the expression turns the whole calculation decimal from that point on. SELECT fiscal_year, ROUND(100.0 * (revenue - cogs) / revenue, 1) AS gross_margin_pct, ROUND(100.0 * (revenue - cogs - operating_expense) / revenue, 1) AS operating_margin_pct, ROUND(100.0 * (revenue - cogs - operating_expense - interest - tax) / revenue, 1) AS net_margin_pct FROM income_statement ORDER BY fiscal_year; Run against the two years above, that returns 63.0 / 25.8 / 17.9 and 60.0 / 22.0 / 14.0. Here is the same expression written four ways, all on the 2024 row, so you can see exactly where the decimal has to sit. What you write What comes back Right? gross_profit / revenue * 100 0 No. The division happens first and rounds to 0. 100 * gross_profit / revenue 60 Right this time, wrong in general. It rounds the answer down to a whole percent. 100.0 * gross_profit / revenue 60.0 Yes. ROUND(100.0 * gross_profit / revenue, 1) 60.0 Yes, and it stops the display carrying twelve decimal places. Row two is the one that catches people, because on this data it returns 60 and 60 is correct. It is correct by luck. Multiply first and the result is a whole number of percent, so 63.0% would come back as 63 and a genuine 22.4% would come back as 22. You would never see the missing four tenths. The wider version of this rule shows up in every growth calculation, and month-over-month growth in SQL works the same trap on a different formula. One more note on ROUND . It does not protect you from integer division, because by the time ROUND sees the value the 0 has already happened. ROUND(0, 1) is 0.0 , which looks like a decimal calculation and is not one. 5. Averaging monthly margins loses 3.1 points You have twelve monthly operating margins. Somebody asks for the year's operating margin. Is averaging the twelve the right move? No, and here is the size of the mistake. This is the same 2024 as above, split into the twelve months it was made of. Cost of goods runs at 40% of each month's revenue, and operating expense is a fixed 4,000,000 of revenue, 1,520,000 of operating expense. Now the two ways to answer "what was our operating margin this year." -- Wrong. Averages twelve percentages as if each month were the same size. SELECT ROUND(AVG(100.0 * (revenue - cogs - operating_expense) / revenue), 1) FROM monthly_pl; -- 18.9
-- Right. Adds the money first, divides once. SELECT ROUND(100.0 * SUM(revenue - cogs - operating_expense) / SUM(revenue), 1) FROM monthly_pl; -- 22.0 Three point one percentage points apart, from the same twelve rows. On 124,000 of profit that the first query cannot see. The reason is that January's revenue of 500,000 count equally in an average of percentages, and they are not equal amounts of business. January lost money, at an operating margin of -6.1%, on less than half the revenue of a good month. Averaging lets that small bad month push the answer down as hard as a large good month pushes it up. The rule that fixes it: add the money, then divide once. A margin is a ratio, and ratios are not averaged, they are recomputed on the totals. This is the same reasoning that makes a class's overall pass rate different from the average of each teacher's pass rate, and it is worth recognising by name, because it shows up whenever a rate is rolled up from parts of different sizes. Picture running that AVG query on your own company's monthly figures. Do you have a January, a quiet month with the same fixed costs as a busy one? If you do, your averaged margin is already wrong, and it is wrong in the optimistic direction whenever the quiet months are the profitable ones. 6. Reading a margin: the four benchmarks A company reports a 2% net margin. Good or bad? Unanswerable, and that is the point. Two percent is healthy for a grocery chain and alarming for a software company. A margin on its own is a number with no verdict attached, and it becomes an analysis only when you put it next to something. There are four somethings, and they answer different questions. Against its own past. Same company, earlier period. This is the one that always works, because the company is its own control: same products, same customers, same accounting. Our example gives 17.9% falling to 14.0%, and that comparison needs no outside information at all. Against the plan. The margin the budget assumed. A miss against plan is a different conversation from a fall against last year, because someone chose the plan number and can be asked why. Budget vs actual variance is the full method for that comparison. Against the industry. Grocery retail runs on net margins of a few percent because it turns over enormous volume at tiny per-item profit. Packaged software can run above 20% because the cost of the next copy is close to nothing. A margin outside its industry's usual band is either a real advantage or an accounting difference, and it is worth finding out which before you present it. Against a specific peer. The most useful comparison, and the one that points at a cause. Take two companies with the same gross margin. Company Revenue Gross margin Operating margin Net margin Ours 4,000,000 60.0% 22.0% 14.0% Peer 4,000,000 60.0% 29.0% 23.5% Identical products, as far as gross margin can tell. Nine and a half points apart at the bottom. The cascade says exactly where to look: the two companies spend 1,240,000 on operating expense, a 320,000 against their 1,000,000 to 510,000. Net income up 560,000. A record year on every line." Every sentence is true. A reader gets no way to tell that the company is keeping less of what it earns, because nothing on the page is measured against anything. The 157,333 below last year's margin Same numbers, plus one division per row. The report now names three separate causes and sizes each one, and the last row converts the whole thing into the only unit a manager acts on, which is dollars. The claim on the top of the email writes itself: we grew 33.3% and net margin fell 3.9 points, which cost 400,000 and net income becomes 4,000,000 of revenue. Net margin is 24.0% and operating margin is 22.0%, so the cascade is upside down. Nothing is broken. Money arrived from somewhere that is not the business, and next year it will not. Whenever net sits above operating, look for a sale, a legal settlement, or a tax credit, and say so in the same sentence as the number. Cost of goods and operating expense are not defined the same way everywhere. Whether shipping, customer support, or the cloud bill sits above or below the gross-profit line is a choice each company makes. Two companies can have genuinely identical economics and gross margins eight points apart. That does not make either wrong, and it does make a gross-margin comparison between two companies weaker than it looks. The comparison inside one company across time is always the safer one. A negative revenue or a zero revenue makes the percent meaningless. A month with no sales divides by zero, and depending on the database that is an error or a null. Guard it: CASE WHEN revenue > 0 THEN 100.0 * profit / revenue END . A blank is honest. A zero is a lie, because 0% margin means you broke even, not that you had no revenue. Points are not percents, and mixing them up is common in writing. Net margin fell from 17.9% to 14.0%. That is a fall of 3.9 percentage points . It is also a fall of about 22% of the margin , because 3.9 is close to a fifth of 17.9. Both are true, they are wildly different numbers, and only one of them belongs in a sentence at a time. Say "points" when you mean the subtraction. Margins hide mix. A company selling two products at 80% and 40% gross margin has an overall gross margin somewhere in between, and that overall number moves whenever the sales mix moves, even if neither product changed at all. If your gross margin dropped and no price changed, check whether you simply sold more of the cheaper thing. Why this works The rule in section five, add the money then divide once, is not a style preference. Combining groups of different sizes can reverse the direction of a rate, an effect first set out formally by Simpson (Simpson, 1951, Journal of the Royal Statistical Society, Series B , 13(2), 238–241) and traced to Yule half a century earlier. Blyth's later treatment gives the plainest statement of the danger: an association that holds in every subgroup can vanish or flip when the subgroups are pooled (Blyth, 1972, Journal of the American Statistical Association , 67(338), 364–366). Averaging twelve monthly margins pools twelve groups of very different sizes while pretending they are equal, which is exactly the condition those papers warn about, and the 3.1-point gap on this page is the mild version of it. The question at the top of each section is not decoration. Attempting an answer before you are given one improves learning of that specific material, an effect measured across sixty-four studies of self-explanation prompts (Bisra, Liu, Nesbit, Salimi, & Winne, 2018, Educational Psychology Review , 30(3), 703–725). Guessing what 2400000 / 4000000 returns before section four told you is why you will still remember it next month. The same evidence says the cheat sheet below works best covered up and recalled rather than reread (Roediger & Karpicke, 2006, Psychological Science , 17(3), 249–255). Using this on your own numbers Retrofitting margins onto every report you have inherited is a slog, and the old ones have owners who like them. Do this instead, in order. Add three columns to the report you already own. Gross, operating and net margin next to the dollars. Three divisions, and the dollars stay exactly where they are so nobody has to relearn the page. Check the division is decimal. Run one row by hand. If a margin comes back as 0, 60 or 1, you have integer division, and sectio

