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

Margin analysis is the work of finding out how much each product, customer, channel and order earns after the costs that come with it, and why that changed since last year. It rests on two measures, gross margin and contribution margin, and on one technique that splits a change in profit into price, volume, mix and cost. Most smaller businesses do it in a spreadsheet a few times a year. AI can rebuild it every week from the ERP and the accounting system, with each figure traced to its invoice line. This guide covers the measures, four ways to cut the numbers, a worked example and how to start.

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 it. Margin analysis asks where that margin comes from: which products, customers, channels and orders produce it, which ones dilute it, and what changed between two periods. The Business Development Bank of Canada (BDC) defines gross margin as “the portion of a company’s revenue left over after direct costs are subtracted,” calculated as gross profit divided by revenue.

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 it “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: the analysis any business can run on its own sales and cost data, whatever its ERP.

The questions it answers are practical:

The measures behind margin analysis

Five measures cover most of the work. The table shows how each one is calculated and what it tells you.

MeasureHow to calculate itWhat it 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 it 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, because 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 and a finance team that reports margin can end up disagreeing about the same order. Cost-plus pricing covers setting prices from cost.

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 it by SKU, 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, warns in The art of SKU rationalization that 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, it needs the landed cost: the purchase price plus freight, duty and handling. SKU rationalization covers what to do with the items at the bottom of the list.

By customer

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 each account takes. McKinsey calls the path from list price to what a business actually keeps the pocket price waterfall. In its 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, such as prompt-payment discounts, cooperative advertising, volume rebates and freight, took another 16.3 percentage points. 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. Margin by customer needs every one of them matched back to the customer who caused it.

By channel

A channel is a route to the customer: direct sales, distributors, retailers, an online store, or quotes for custom work. Each has its own price level and its own cost to serve. A food producer that sells the same product to a grocery chain and to food service can compare the two 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. 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 you hold limits what you can sell, and the margin on that stock decides what it earns. Inventory optimization covers the stock side. The example below 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 that caused it. The ACCA, a professional accounting body, explains the method in an examiner’s report for its Performance Management exam. The mix and quantity variances, it says, “are just a further analysis of the sales volume variance,” valued at standard contribution when you use marginal costing. The same method compares this year with last year.

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 it 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. That points the next conversation at which products the sales team promoted, as well as at the discount on Line A.

For two lines, this takes an afternoon in a spreadsheet. For 3,000 items and 400 customers, it needs software, and it needs to run again every month.

How margin analysis is done by hand

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 they 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, and the results come 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 it, which is most of the effort.

It rebuilds the analysis every week

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

It reads 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 them into structured data, so the real freight on each shipment and the landed cost of each receipt can be matched to the sale. AI invoice processing and text extraction from images cover how to test that reading on your own documents.

It explains the change in plain language

After the bridge is calculated, a language model can draft the commentary: which customers moved, which products drove the mix effect and which price changes held. Link each sentence to the rows behind it, so a controller can check it. 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. It can translate instructions like “sort on quantity from smallest to largest” or “show average cost per category” into “the corresponding rows, columns, filters, and aggregations.”

It flags what needs a decision

Rules and models can watch for the patterns a person would act on: a customer whose margin fell three months in a row, an item sold below its floor price, a supplier cost increase that never reached the price list, or a customer about to reach a rebate tier. Each flag goes to a named person who decides what to do. Human in the loop covers designing that review.

It tests 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: 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. It found that a 1% price rise, with volumes stable, “would generate an 8 percent increase in operating profits,” nearly 50% more than the effect of a 1% cut in variable costs. Price optimization and pricing intelligence cover setting prices from cost, demand and the market, and AI financial modeling covers building the financial model from the ERP and the books.

The data margin analysis needs

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

DataWhere it usually livesWhat it 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, CRMThe groupings for the analysis
General ledgerAccounting systemThe totals the analysis must tie back to

Test the result against the books first. The gross margin the analysis reports for last year must match the income statement, with any difference explained line by line. Fix that before anyone uses the numbers for a decision. AI for ERP covers getting data out of the ERP you run, and legacy ERP automation covers older systems installed on your own server.

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 it to the general ledger until every difference is explained.
  4. Add the costs the invoice line misses, starting with freight and rebates.
  5. Build the price, volume and mix bridge for the last two years and check it with your controller.
  6. Run it every month, with a short written explanation that a person reviews before it goes out.
A question to ask first

Which costs in our margin today 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 Derik which ERP and accounting system you run and which margin question you cannot answer today. He will tell you what your data can support.

Start a conversation

Risks and limits

How ThriveAI helps

ThriveAI is an AI engineering company in Ottawa that builds private AI systems on a company’s own data, for businesses that make, move or sell physical goods. For margins, that means joining the sales lines, costs, rebates and freight your ERP and accounting system already hold, so margin by product, customer and channel stays current, and flagging the lines whose margin moved for a named person to review. Every answer shows where it came from.

ThriveAI’s systems read your ERP and accounting system as they are, and every connection only reads data. They are designed to keep each client’s data on its own server in Canada. You choose a model on that server or a hosted model under a written zero data retention agreement, and a hosted model may process requests outside Canada. Derik Lawlis, the founder, leads every project and stays close to the build. About ThriveAI covers the company.

Questions people ask

What is margin analysis?
Margin analysis measures how much each product, customer, channel or order earns after its costs, and explains why margin changed between two periods. It uses gross margin, contribution margin and a price, volume and mix bridge, built from 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?
It splits a change in profit between two periods into four parts: the effect of price changes, the effect of selling more or fewer units, the effect of a shift toward higher or lower margin items, and the effect of cost changes. 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 its 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, and 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.