Metric

What is cost per customer, and how do you measure it in Metabase?

Definition

Cost per customer allocates infrastructure spend to the customers it serves — the foundation of unit economics. Direct costs (dedicated resources, tenant-tagged usage) allocate cleanly; shared platform costs need an explicit distribution rule, and that rule changes the answer.

Formula: Cost per customer = directly attributable cost + (shared cost × distribution weight), per customer per period

What data do you need?

  • Cost allocated to customers via tags, tenancy mapping, or a cost platform's dimensions
  • A documented shared-cost distribution rule (even, usage-based, or revenue-based)
  • Usage drivers per customer (requests, storage, compute) for driver-based allocation
  • Revenue per customer for margin views
  • A stable customer key shared across cost and revenue systems

SQL pattern

Cost per customer with shared cost distributed by usagePostgreSQL
WITH direct AS (
  SELECT customer_id, SUM(cost_usd) AS direct_cost
  FROM customer_cost_allocations
  WHERE month = {{month}}
  GROUP BY 1
), shared AS (
  SELECT SUM(cost_usd) AS shared_cost
  FROM shared_platform_costs
  WHERE month = {{month}}
), usage AS (
  -- Aggregate first: several usage rows per customer would otherwise
  -- fan out the join and double-count direct cost.
  SELECT customer_id, SUM(usage_units) AS usage_units
  FROM customer_usage
  WHERE month = {{month}}
  GROUP BY 1
), usage_weights AS (
  SELECT
    customer_id,
    1.0 * usage_units / NULLIF(SUM(usage_units) OVER (), 0) AS weight
  FROM usage
), customers AS (
  -- Every customer with direct cost OR usage, so no shared cost is stranded.
  SELECT customer_id FROM direct
  UNION
  SELECT customer_id FROM usage_weights
)
SELECT
  c.customer_id,
  ROUND(COALESCE(d.direct_cost, 0), 2) AS direct_cost,
  ROUND(s.shared_cost * COALESCE(w.weight, 0), 2) AS shared_cost_allocated,
  ROUND(
    COALESCE(d.direct_cost, 0) + s.shared_cost * COALESCE(w.weight, 0), 2
  ) AS total_cost
FROM customers c
LEFT JOIN direct d USING (customer_id)
LEFT JOIN usage_weights w USING (customer_id)
CROSS JOIN shared s
ORDER BY total_cost DESC;

Common pitfalls

Distributing shared cost without documenting the rule.→ State the rule on the dashboard; even vs. usage-based distribution can flip which customers look profitable.
Reporting cost per customer without revenue.→ Join revenue for margin — a high-cost customer paying proportionally more is fine; a low-cost one at negative margin isn't.
Using the mean when customer costs are heavily skewed.→ Report median and p90 cost per customer, and show the top of the distribution as its own table.

Where does this metric apply?

This metric commonly uses data from CloudZero, AWS Billing, Google Cloud Billing, Kubecost, plus any warehouse models built on raw billing exports at the same grain.

Dashboards

Integrations

Metrics

Analytics

FAQ

How do I start if nothing is tagged by customer?
Start with the slice that can be attributed — tenant-level databases, per-customer storage — and distribute the rest by a usage driver. Even a partial direct-cost layer plus an explicit rule beats waiting for perfect tagging.
How often should cost per customer be reviewed?
Monthly grain is the workhorse — daily cost per customer is noisy and billing lags smear it. Trend the median monthly, and investigate customers whose cost grows faster than their revenue two months running.