EnableYourData.com

KPI · Sales

Gross margin per customer: formula and example.

Gross margin per customer is a customer's revenue minus the cost of the goods that customer bought, in euros or as a percentage of revenue. It shows which customers genuinely make money, not just generate revenue. It underpins decisions on pricing, discounts and where to focus account management.

Gross margin per customer formula

(Customer revenue − cost of goods sold to that customer) ÷ customer revenue × 100%

Worked example

Customer A of Acme Groothandel bought €96,000 worth of goods in 2025 at a cost of €72,000: a gross margin of €24,000, or 25%. Customer B bought €48,000 at a cost of €31,200: a gross margin of €16,800, or 35%. Customer A brings in more margin in euros, customer B more per euro of revenue.

Fictitious figures for Acme Groothandel, a sample wholesaler.

How to read this KPI

A higher gross margin per customer means that customer contributes more towards covering your fixed costs. Look at both the amount and the percentage: large customers often deliver a lot of margin in euros at a lower percentage. Compare customers within the same segment and track each customer's trend over the years.

Pitfalls with gross margin per customer

  • Using a standard cost price that no longer matches the actual purchase price.
  • Not allocating rebates, retrospective discounts and credit notes to the customer.
  • Ignoring costs that vary widely by customer, such as shipping or returns.

SQL & DAX

Calculating gross margin per customer in SQL and DAX

Two examples on a fictitious data warehouse for Acme Groothandel: a PostgreSQL query and a measure for a Power BI model. Adjust table and column names to your own model.

SQL · PostgreSQL
SELECT c.customer_id, c.name,
       SUM(ol.quantity * ol.unit_price - ol.discount_amount) AS revenue,
       SUM(ol.quantity * ol.unit_cost) AS cogs,
       SUM(ol.quantity * (ol.unit_price - ol.unit_cost) - ol.discount_amount) AS gross_margin,
       ROUND(100.0 * SUM(ol.quantity * (ol.unit_price - ol.unit_cost) - ol.discount_amount)
             / NULLIF(SUM(ol.quantity * ol.unit_price - ol.discount_amount), 0), 1) AS margin_pct
FROM order_lines ol
JOIN orders o USING (order_id)
JOIN customers c ON c.customer_id = o.customer_id
WHERE o.order_date >= date_trunc('year', current_date)
GROUP BY c.customer_id, c.name
ORDER BY gross_margin DESC;
DAX · Power BI
Gross Margin =
SUMX(SalesLines, SalesLines[Quantity] * (SalesLines[UnitPrice] - SalesLines[UnitCost]) - SalesLines[DiscountAmount])

Gross Margin % =
DIVIDE([Gross Margin], SUMX(SalesLines, SalesLines[Quantity] * SalesLines[UnitPrice] - SalesLines[DiscountAmount]))

In ENABLE

Tracking this KPI in ENABLE

Plain-language questions

Ask for gross margin per customer per month, customer or product in the SQL Explorer with AI. The AI writes the SQL, you see the query and run it yourself; the AI only receives metadata.

Read more →

In your Power BI dashboard

Define the KPI as a measure in your Power BI model and show it in the portal, with "Last refreshed" next to it. Access profiles and optional row-level security decide who sees which figures.

Read more →

Custom dashboards (pilot)

Add the KPI as a tile to a custom dashboard, compared with last year. The Dashboard Builder is a pilot and can be switched on per client.

Read more →

Monthly targets

With the built-in Targets app you set a target for the KPI per month, so you see actuals and target side by side.

Read more →

FAQ

Frequently asked questions

How do you calculate gross margin per customer?

For each customer, subtract the cost of goods sold from revenue after discounts. Divide the result by revenue to get the margin percentage. With €96,000 in revenue and €72,000 in cost, gross margin is €24,000, or 25%.

What is the difference between gross margin per customer and customer profitability?

Gross margin per customer only deducts the cost of goods, while customer profitability also deducts the cost to serve the customer. That includes shipping, returns, account management and payment discounts. Customer profitability is more complete, but requires a cost allocation method you need to agree first.

What should you do with low-margin customers?

With low-margin customers, first find out what is causing it: discounts, product mix or additional costs. Revising discount agreements or offering different products often helps. Ending the relationship is only an option if the customer is loss-making after all costs.

Use AI on your own data. Securely, and without the headache.

In an online demo we show how ENABLE makes your data securely available and how you build on it: describing an app in the AI Builder, plain-language questions, dashboards and APIs. And how we set it up and manage it for you.