Margin analysis: by product, customer and mix, and how AI keeps it current

Margin analysis measures what each product, customer, channel, and order earns after costs, and why that changed.

A row of new laser cutting machines lined up on the floor of a large, bright factory hall

What margin analysis is

Margin is what a sale leaves after the costs that come with the sale. Margin analysis asks where that margin comes from. The analysis finds which products, customers, channels, and orders produce margin, which ones dilute margin, and what changed between two periods. The Business Development Bank of Canada (BDC) calculates gross margin as gross profit divided by revenue. BDC defines gross margin as “the portion of a company’s revenue left over after direct costs are subtracted.”

The term has a second meaning for SAP users. In SAP S/4HANA, Margin Analysis is the name of the account-based profitability module. SAP says that the module “helps to ensure that Management Accounting and Financial Accounting (FI) are reconciled at the account level at all times.”

This guide uses the general sense: an analysis of a company’s own sales and cost data, whatever the ERP.

The questions that margin analysis answers are practical:

The measures behind margin analysis

Five measures cover most of the work. The table shows how to calculate each measure and what each measure tells you.

MeasureHow to calculate the measureWhat the measure tells you
Gross margin(Revenue − cost of goods sold) ÷ revenueHow much of each sales dollar is left after the direct cost of the goods
Contribution marginPrice − variable costs, per unit or in totalWhat each sale adds toward fixed costs and profit
Contribution margin ratioContribution margin per unit ÷ price per unitThe share of each sales dollar that covers fixed costs
Pocket marginPrice after every discount, rebate, early-payment discount, and freight cost, minus costWhat you keep from one customer or one order
Markup(Price − cost) ÷ costThe percentage added to cost to set a price

OpenStax’s managerial accounting textbook defines contribution margin as “the amount by which a product’s selling price exceeds its total variable cost per unit.”

The same section explains why the measure matters. Knowing how each product contributes “allows managers to make decisions such as which product lines they should expand or which might be discontinued.”

Gross margin is the figure on the income statement. For a decision about one product or one customer, use contribution margin. Fixed costs such as rent do not change when one order is won or lost.

Margin and markup describe the same dollars over different bases. A part that costs $80 and sells for $100 has a markup of 25% on cost and a margin of 20% on price. To convert, divide the markup by one plus the markup: 0.25 ÷ 1.25 = 0.20. A sales team that quotes from a markup table can disagree about the same order with a finance team that reports margin. For setting prices from cost, see cost-plus pricing.

Four ways to cut margin

The totals on an income statement hide where margin is made. The same data, cut four ways, answers four different questions.

By product

Margin by product shows which items carry the business, whether you measure margin by SKU (stock-keeping unit), by product family, or by job. The weak point is cost. A standard cost set two years ago, or overhead spread evenly across every item, makes low-volume items look better than they are. Plante Moran, an accounting and advisory firm, describes one such cost error in The art of SKU rationalization. When costing leaves out changeover time, high-volume parts end up subsidizing the changeovers that low-volume parts cause. In a plant, product margin needs the real setup time and scrap of each item. In a distribution business, product margin needs the landed cost: the purchase price plus freight, duty, and handling.

Machined steel shafts, brass and steel gears, and small bushings laid out on a white surface
Product margin needs the real setup time and scrap of each item.

By customer

A distributor sees margin by customer with a tool that matches every discount, rebate, freight bill, and return to the customer behind the cost. Two customers can buy the same item at the same list price and leave different margins. The difference sits in discounts, rebates, payment terms, freight, returns, order size, and the staff time that each account takes. McKinsey calls the path from list price to what a business actually keeps the pocket price waterfall. In the McKinsey example of a lighting supplier, discounts shown on the invoice put average invoice prices 32.8% below list. Deductions that never appeared on the invoice took another 16.3 percentage points. Those deductions included prompt-payment discounts, cooperative advertising, volume rebates, and freight. The average pocket price ended up at about half the list price.

Most of those deductions live in the general ledger, in rebate spreadsheets, and in freight bills, away from the invoice line. Each deduction has to be matched back to the customer who caused that deduction.

By channel

A channel is a route to the customer: direct sales, distributors, retailers, an online store, or quotes for custom work. Each channel has a different price level and a different cost to serve. Take a food producer that sells the same product to a grocery chain and to food service. The producer can compare the two channels after promotion spending, pack sizes, and freight. Margin by channel shows whether growth in one route is diluting the total.

By mix

Mix is the share of each product, customer, or channel in total sales. A margin mix analysis measures how a shift in that share changes total margin. When the mix shifts toward lower-margin items, total margin can fall even when every price holds and sales grow. Product mix and inventory mix are linked. The stock that you hold limits what you can sell, and the margin on that stock decides what the stock earns. The following example separates the mix effect from price, volume, and cost.

Price, volume, and mix: a worked example

A price, volume, and mix analysis, often called a PVM bridge, splits the change in contribution between two periods into the parts behind the change. The ACCA, a professional accounting body, explains the method in an examiner’s report for the ACCA Performance Management exam. The same method compares this year with last year. Under marginal costing, which counts only variable costs in product cost, the variances are valued at standard contribution. The report says that the mix and quantity variances “are just a further analysis of the sales volume variance.”

Here a distributor sells two product lines. The numbers are made up for this example.

Line A, standard fittingsLine B, custom assemblies
Units sold last year12,0004,000
Price last year$20.00$50.00
Variable cost per unit last year$14.00$30.00
Units sold this year16,0004,000
Price this year$19.50$51.00
Variable cost per unit this year$14.25$30.50

Revenue rose from $440,000 to $516,000, or 17%, and units rose 25%. Contribution rose only $14,000, from $152,000 to $166,000, and the contribution margin fell from 34.5% to 32.2% of sales. The bridge shows why.

EffectHow the effect is calculatedChange in contribution
Volume at last year’s mix4,000 more units × last year’s average contribution of $9.50 a unit+$38,000
MixAt last year’s 75/25 split, 20,000 units would have been 15,000 of A and 5,000 of B. The year sold 1,000 more A at $6.00 and 1,000 fewer B at $20.00−$14,000
Price16,000 × −$0.50 on A, plus 4,000 × $1.00 on B−$4,000
Cost16,000 × −$0.25 on A, plus 4,000 × −$0.50 on B−$6,000
TotalThe sum of the four effects+$14,000

The mix line is the largest negative. Price and cost together take $10,000, and the shift toward Line A, the lower-margin line, takes $14,000. The next conversation is about which products the sales team promoted, as well as the discount on Line A.

For two lines, this analysis takes an afternoon in a spreadsheet. For 3,000 items and 400 customers, the analysis needs software that runs the bridge again every month.

A long, bright production hall with rows of teal machines topped with orange spools and green crates along a clean centre aisle
MixEvery line on a floor like this one carries a different margin. The bridge shows which lines moved the total.

How margin analysis is done by hand

Margin by order is often unknown until month end, because freight, rebates, and credit notes post to the ledger after the invoice. In most smaller companies, someone in finance builds the analysis in a spreadsheet a few times a year:

  1. Export invoice lines from the ERP: date, customer, item, quantity, and price.
  2. Look up a cost for each item, usually the standard cost on the item card.
  3. Spread freight, rebates, and returns from the general ledger as a percentage, because those costs are not on the invoice line.
  4. Build pivot tables by product, customer, and region.
  5. Explain the change from last year in a slide.

Each step has a weak point. Standard costs drift away from what the business actually pays. Freight and rebates spread as a flat percentage hide the customers that cost the most to serve. Credit notes and returns post later and often land in the wrong month. By the time the analysis is finished, the quarter has moved on, too late to change that quarter’s prices.

What AI changes in margin analysis

The arithmetic stays the same. Software takes over the work around the arithmetic, which is most of the effort.

Software rebuilds the analysis every week

A scheduled job pulls the week’s invoice lines, credit notes, and receipts from the ERP. The job matches each sale to the cost of the goods behind the sale, and recalculates margin by product, customer, and channel. Keep the calculations in code or in SQL, the query language of databases, because code gives the same answer every time. Use a language model to read documents and explain results, and keep the model away from the sums.

Models read the documents that hold the real costs

Freight bills, supplier invoices, rebate agreements, and customs entries often arrive as PDFs or emails. Language and vision models read these documents into structured data. The real freight on each shipment and the landed cost of each receipt can then be matched to the sale.

A model explains the change in plain language

After the bridge is calculated, a language model can draft the commentary. The commentary covers which customers moved, which products drove the mix effect, and which price changes held. Link each sentence to the rows behind the sentence, so that a controller can check each claim. Some ERPs add a plain-language layer on top of their own data. In Business Central, Microsoft’s analysis assist is a preview feature for analyzing list data. The feature translates plain instructions into “the corresponding rows, columns, filters, and aggregations,” in Microsoft’s words. One instruction that the feature accepts is “sort on quantity from smallest to largest,” and another is “show average cost per category.”

Rules flag what needs a decision

Rules and models can watch for the patterns that a person would act on. Examples include a customer whose margin fell three months in a row, or an item sold below the item’s floor price. Others are a supplier cost increase that never reached the price list, and a customer about to reach a rebate tier. Each flag goes to a named person who decides what to do.

Test a change before you make it

With margin by product and customer in one place, you can test a change against last year’s data. The change might be a 2% increase on one product family, a minimum order charge, or dropping a slow line. In a 2003 article, McKinsey worked through the average income statement of an S&P 1500 company. The effect of a 1% price rise came out nearly 50% larger than the effect of a 1% cut in variable costs. With volumes stable, McKinsey found that a 1% price rise “would generate an 8 percent increase in operating profits.”

The data margin analysis needs

Everything comes from systems that the business already runs: the ERP, the accounting system, and a few spreadsheets.

DataWhere the data usually livesWhat the data adds
Invoice lines and credit notesERP sales moduleRevenue by item, customer, date, and price
Item cost: standard cost, purchase receipts, bills of materials, and routingsERP inventory, purchasing, and manufacturingThe cost of goods sold for each item
Freight, duty, and handlingFreight bills, customs entries, general ledgerLanded cost and cost to serve
Rebates, discounts, and payment termsCustomer agreements, spreadsheets, general ledgerThe pocket price for each customer
Returns and warranty claimsERP, service recordsMargin lost after the sale
Customer, channel, and sales repCustomer master, CRM (customer relationship management system)The groupings for the analysis
General ledgerAccounting systemThe totals that the analysis must tie back to

Test the result against the books first. The gross margin that the analysis reports for last year must match the income statement, with any difference explained line by line. Fix any gap before anyone uses the numbers for a decision. For getting data out of the ERP that you run, see AI for ERP.

A narrow warehouse aisle between tall orange racks of blue drums and labelled tubs, with a reach truck parked at the far end
Freight, duty, and handling sit in bills and the ledger, away from the invoice line.

How to start small

  1. Pick one question. For example: which 20 customers made the least contribution last year after freight and rebates?
  2. Pull 24 months of data for one product family or one region: invoice lines, credit notes, receipts, and the related ledger entries.
  3. Tie the data to the general ledger until every difference is explained.
  4. Add the costs that the invoice line misses, starting with freight and rebates.
  5. Build the price, volume, and mix bridge for the last two years, and check the bridge with your controller.
  6. Run the bridge every month, with a short written explanation that a person reviews before the explanation goes out.
A question to ask first

Which costs in your margin are spread by a flat percentage? Those lines are where the analysis is most likely to be wrong, and where real data changes the answer most.

Find out what your margin data can show

Tell us which ERP and accounting system you run, and which margin question you cannot answer. We will tell you what your data can support.

Derik Lawlis, founder
Start a conversation

Risks and limits

How ThriveAI helps

ThriveAI, an AI engineering company in Ottawa, builds private AI systems on a company’s own data for businesses that make, move, or sell physical goods. For margins, the system joins the sales lines, costs, rebates, and freight that your ERP and accounting system already hold. Margin by product, customer, and channel then stays current. The system flags the lines whose margin moved, for a named person to review. Every answer shows the record behind the answer.

ThriveAI’s systems read your ERP and accounting system as they are, and every connection is read-only. Your company has a copy of the data reserved for your team. ThriveAI hosts that copy, or you host the copy on your own servers. You choose a model where the copy is hosted, or a hosted model under a written zero data retention agreement. A hosted model may process requests in another country. Derik Lawlis, the founder, leads every project and stays close to the build. For more about the company, see About ThriveAI.

Questions people ask

What is margin analysis?
Margin analysis measures how much each product, customer, channel, or order earns after costs, and explains why margin changed between two periods. The analysis uses gross margin, contribution margin, and a price, volume, and mix bridge. The inputs are the sales and cost data in the ERP and the accounting system.
How do you calculate margin analysis?
Start with revenue and the cost of each sale. Gross margin is revenue minus cost of goods sold, divided by revenue. Contribution margin is price minus variable costs. Group the results by product, customer, and channel. Then split the change from last year into price, volume, mix, and cost effects.
Is 20% margin the same as 25% markup?
Yes, when both describe the same price and cost. A part that costs $80 and sells for $100 has a 25% markup on cost and a 20% margin on price. Margin equals markup divided by one plus markup, so 0.25 divided by 1.25 is 0.20.
What is the difference between gross margin and contribution margin?
Gross margin subtracts the cost of goods sold, which for a manufacturer usually includes a share of fixed factory overhead. Contribution margin subtracts only the costs that change with each sale, such as materials, freight, and commissions. Contribution margin is the better guide for a decision about one product or one customer.
What is a price, volume, and mix analysis?
A price, volume, and mix analysis splits a change in profit between two periods into four parts. The parts are price, volume (selling more or fewer units), mix (a shift toward higher or lower margin items), and cost. The four parts add up to the total change.
Is margin analysis the same as marginal analysis?
No. Marginal analysis is an economics method that compares the extra benefit and the extra cost of one more unit. Margin analysis is a management accounting practice that measures where a business earns margin.
Can AI do margin analysis?
AI can pull and match the data, read freight bills and rebate agreements, rerun the analysis every week, flag changes, and draft an explanation. The calculations belong in code that gives the same answer every time. A person decides what to do about a price, a product, or a customer.

Contact

Start with the margin question you cannot answer

Tell Derik which systems hold your sales and cost data and which product or customer worries you. He will tell you whether your data can answer it, down to the invoice line.

Prefer to talk? Book a meeting.

Your message goes to Derik Lawlis, the founder.