Menu

How it works

Without a semantic layer, “revenue” ends up defined in five dashboards, three notebooks and a spreadsheet, each with slightly different refund, tax or currency logic. A semantic layer defines it once, in code, and every consumer asks for it by name.

A definition captures what dimensional modelling teaches about aggregation:

  • Entities and joins: how orders, customers and products relate, so the layer can join safely without fanning out rows.
  • Dimensions and time grains to slice by.
  • Measures and metrics: how each measure aggregates, which dimensions it can be summed across, and ratios defined as numerator and denominator aggregated separately, then divided.
  • Access rules and documentation.

When a client asks for net_revenue by region by month, the layer generates the SQL at that grain. Implementations include the dbt Semantic Layer (powered by MetricFlow), Snowflake semantic views, Databricks metric views, Cube, LookML in Looker and Power BI semantic models. A growing use is grounding AI assistants, which answer questions far more reliably against governed metric definitions than against raw tables.

The cost is another layer to maintain, uneven tool support, and the hard part: getting stakeholders to agree one definition per metric and an owner for each.

Example

The ratio rule a semantic layer enforces. Average order value must be total revenue divided by total orders, not the average of daily averages.

CREATE TABLE fct_orders (order_id text PRIMARY KEY, order_date date, net_amount numeric);
INSERT INTO fct_orders VALUES
  ('O-1', '2026-03-02', 100), ('O-2', '2026-03-02', 300),
  ('O-3', '2026-03-02', 200), ('O-4', '2026-03-03', 20);

WITH daily AS (
  SELECT order_date, sum(net_amount) / count(DISTINCT order_id) AS daily_aov
  FROM fct_orders GROUP BY order_date
)
SELECT (SELECT round(sum(net_amount) / count(DISTINCT order_id), 2) FROM fct_orders) AS correct_aov,
       (SELECT round(avg(daily_aov), 2) FROM daily)                                   AS average_of_daily_aov;
 correct_aov | average_of_daily_aov
-------------+----------------------
      155.00 |               110.00

Common mistakes

  • Treating a semantic layer as “just some views”, which fixes the grain and loses the ability to compute metrics at any slice.
  • Pre-aggregating ratios in tables instead of defining them from their components.
  • Launching without agreed metric owners, so the layer holds three versions of revenue.
Search
Filter by type