Skip to content
elastly
Book a demo

Margin analysis: how to analyze margin by customer, product and rep

Margin analysis shows what your margin is and why it moved. The formulas, a step-by-step method, the weighted-margin trap, and a price, cost and mix example.

Mohamed AshrafOct 22, 2026 · 6 min read

Margin analysis is the process of measuring your margins and explaining why they changed. For a distributor that means gross margin weighted by revenue and broken down by customer, product, segment and rep. Each change is then split into price, cost and mix. Done this way it answers the question a margin report alone cannot: what moved the number, and who owns the fix.

What is margin analysis?

A margin is the share of revenue left after a set of costs. Margin analysis calculates those shares for a period, compares them with a baseline such as last quarter or the budget, and traces the difference to its causes.

Finance teams usually stop at the company level: gross margin, operating margin, net margin. That shows whether the business is healthy, but gives a pricing manager nothing to act on. For a distributor the useful version goes down to the invoice line, because that is where prices are set and where margin is won or lost.

Margin analysis vs marginal analysis

The two terms are close enough to be confused, and search engines often mix them.

Question
Margin analysisWhat did we earn, and why did it change?
Marginal analysisIs one more unit worth its extra cost?
Looks at
Margin analysisPast sales by customer, product and period
Marginal analysisThe next decision at the margin
Used for
Margin analysisPricing, discounting and cost reviews
Marginal analysisProduction volume and capacity choices

The margins worth analyzing

Distributors need three margins. Each answers a different question.

  • Gross margin

    Revenue minus cost of goods sold. The pricing view of every line.

  • Contribution margin

    Gross margin minus variable costs such as freight, commission and rebates.

  • Pocket margin

    What a customer earns you after every on-invoice and off-invoice cut.

Operating and net margin matter to the business, but overhead such as rent and salaries is not caused by a single customer or SKU. Allocating it to lines starts arguments about the allocation key and changes no pricing decision. The gross margin formula and the contribution margin formula guides cover the calculations in detail, and the price waterfall shows how pocket margin is built.

Weighted margin: the mistake in most margin reports

The most common error in a margin analysis is averaging percentages. A report that averages the margin of each line, customer or SKU gives a small order the same weight as a large one.

Take three customers in one quarter:

Customer, revenueGross margin
Fleet account, $40,00018%
Workshop A, $5,00042%
Workshop B, $5,00036%

The simple average of the three margins is 32%. The business earned $7,200 + $2,100 + $1,800 = $11,100 of gross profit on $50,000 of revenue.

Formula
Weighted gross margin=Total gross profit÷Total revenue
Example$11,100÷$50,000=22.2%

A report built on the average would show 32% while the business earned 22.2%. Always divide total gross profit by total revenue for any group of lines, and rank groups by gross profit dollars, not by percentage, so the largest money sits at the top.

How to do a margin analysis, step by step

  1. Decide the question

    Which customers, products or reps missed margin last quarter, and by how much.

  2. Export invoice lines with cost

    Date, customer, segment, SKU, category, rep, quantity, net price, unit cost. Include credits.

  3. Check the costs before anything else

    Lines with zero or missing cost inflate margin and hide real problems.

  4. Tie the totals to the books

    Revenue and cost of goods sold should match the income statement for the period.

  5. Slice and weight

    Gross profit and weighted margin by customer, segment, SKU, category and rep.

  6. Bridge the change

    Split the change against the baseline into price, cost and mix.

  7. Assign each finding

    Every finding gets an owner, an action and a money figure.

Slice by customer, product and rep

The company margin is an average of quite different businesses. In the example below the distributor earned $825,600 of gross profit on $3.2M of revenue in the second quarter, a 25.8% margin. By segment it looks like this:

Gross profit by segment, second quarter
  • Contractors$1.4M revenue, 25.5% margin$357,000
  • OEM$600k revenue, 27.0% margin$162,000
  • Workshops$500k revenue, 31.4% margin$156,800
  • Fleet$700k revenue, 21.4% margin$149,800

Contractors are the largest profit pool and sit just under the company margin, so a single point there is worth $14,000 a quarter. Fleet has the lowest margin on the second-largest revenue. Workshops earn the best margin but the smallest revenue. Each segment needs a different conversation, and the company figure hides all three.

Repeat the same cut by SKU and category to find products priced below their peers, and by rep to find who discounts most. When one cut looks wrong, drill into the lines behind it before drawing a conclusion.

Why margin moved: price, cost and mix

A margin change has three main causes. A margin bridge separates them.

  • Price: the same items sold at different prices than in the baseline.
  • Cost: the same items bought or landed at different costs.
  • Mix: the share of sales moved toward lower-margin or higher-margin customers and products.

In the example, gross margin fell from 27.0% in the first quarter to 25.8% in the second. Repricing every second-quarter line at first-quarter prices and costs, then at first-quarter mix, splits the 1.2 points:

−0.9 ptsPrice: lower prices on the same items
+0.3 ptsCost: better buying on two lines
−0.6 ptsMix: more fleet, less workshop revenue

27.0 − 0.9 + 0.3 − 0.6 = 25.8. The bridge puts most of the drop on price: the same items sold for less. That points to the lines, customers and reps behind it, not to purchasing or the market.

Always compute the bridge in a fixed order and report the order with it. Price, then cost, then mix gives slightly different numbers than mix first, and nobody can reproduce a bridge whose order is unknown.

A margin analysis template

A spreadsheet that supports everything above needs one row per invoice line and these columns:

  • Date, invoice number, customer, customer segment or price level
  • SKU, category, brand, rep
  • Quantity, net unit price, unit cost, list price
  • Revenue (quantity × net price), cost (quantity × unit cost), gross profit

Add pivot tables for gross profit and weighted margin by segment, SKU and rep, and a second sheet with the baseline period so you can bridge the two. Keep cost and price as values captured at the sale date, never as lookups to today's cost.

Where a monthly margin analysis breaks

A monthly analysis has three limits for pricing.

It arrives after the quotes that caused the change, so the fix starts weeks late. It averages within each slice, so a segment that looks fine can hide one SKU sold across a wide range of prices. And it shows where margin is low, not which specific prices should change. The next step is a line-level search for margin leakage: sales below floor, below cost, below peers, and segments drifting with no price change.

Elastly keeps this analysis current from the invoice lines it syncs from your ERP and ranks every finding by money, with the lines behind it. The question after the bridge, which prices to change, gets its answer on the same screen. Connect your ERP and see your own margin leaks for free.

Run margin analysis on your own data

Free in your trialYour leak report, from your own dataConnect NetSuite with a view-only role. After the first sync, see where margin leaks, ranked by money at stake.Read the margin leakage guide
Get your free leak report

Common questions

Start with gross margin: revenue minus cost of goods sold, divided by revenue. Calculate it for the whole business, then for each customer, product and rep, always weighted by revenue. Compare it with the previous period and split the change into price, cost and mix, so you know what moved it.