Software & OS

What Is a Semantic Layer? Definition and Examples

A semantic layer is a shared model that sits between your database or warehouse tables and the tools people use to query them. It defines business terms such as "revenue" or "active customer" once, so every dashboard, spreadsheet and AI tool calculates them the same way.

The rest of this article shows the problem it solves, what a definition looks like in two real products, and where the term gets used loosely.

What problem does a semantic layer solve?

Raw warehouse tables hold columns like amount, status and created_at. They do not say whether "revenue" should include refunds, tax or cancelled orders. Without a shared definition, each analyst or BI tool writes its own query, and the numbers drift apart.

Example of the drift (illustrative SQL, not from any vendor):

-- Dashboard A
SELECT SUM(amount) FROM orders;

-- Dashboard B
SELECT SUM(amount) FROM orders WHERE status = 'completed';

Both are called "revenue" on their dashboards, and they return different totals. A semantic layer moves that logic into one governed definition. dbt describes its version this way: it "eliminates duplicate coding by allowing data teams to define metrics on top of existing models and automatically handling data joins." If a definition changes, dbt says it is refreshed everywhere it is invoked.

What does a semantic layer contain?

Products differ in vocabulary, but the pieces are similar:

  • Measures or metrics: quantitative values that get aggregated, such as a count of orders or a sum of revenue.
  • Dimensions: categorical attributes you group or filter by, such as city, product or month.
  • Relationships between tables: so a query that combines a measure from one table with a dimension from another gets the join right without the user writing it.
  • An access surface: an API, a SQL interface or a set of connectors that tools query instead of the raw tables.

Microsoft describes its Power BI semantic models as "a logical description of an analytical domain, with metrics, business friendly terminology, and representation." It adds that such a model is typically a star schema: facts that represent a domain, and dimensions you slice and filter by.

Example: a measure and a dimension in Cube

Cube is an open semantic layer product. Its documentation shows a cube (a table plus its definitions) with measures and dimensions in YAML. This excerpt is adapted from the Cube data modeling overview:

cubes:
  - name: users
    sql_table: users

    measures:
      - name: count
        sql: id
        type: count
      - name: paying_count
        sql: id
        type: count
        filters:
          - sql: "{CUBE}.paying = 'true'"
      - name: paying_percentage
        sql: "1.0 * {paying_count} / {count}"
        type: number
        format: percent

    dimensions:
      - name: city
        sql: city
        type: string

Here paying_percentage is defined once, in terms of two other measures. Anyone who asks for it by city gets the same calculation. Cube also has views, which its docs say "sit on top of cubes and create a facade of your whole data model," controlling what consumers can see.

Example: metric types in dbt

The dbt Semantic Layer is powered by MetricFlow. You define metrics in your dbt project, on top of existing models. dbt supports five metric types:

TypeWhat it does (per dbt docs)
SimpleAggregates a single column expression in a semantic model, for example sum or count.
CumulativeAggregates a simple metric over a given period, or over all recorded time if no period is set.
DerivedCalculates from other metrics, for example gross_profit as revenue minus cost.
RatioDivides a numerator metric by a denominator metric, with optional filters.
ConversionTracks when a base event and a later conversion event occur for the same entity within a set time.

dbt's documentation shows a simple metric like this:

metrics:
  - name: my_simple_metric
    description: A metric description
    type: simple
    label: My Simple Metric
    agg: sum
    expr: revenue_column

The surrounding nesting depends on whether you define it inside a model's semantic_model block or at the top level, so check the dbt page for your version before copying it. As of November 2026, dbt's docs say defining and querying metrics requires a dbt Starter or Enterprise-tier account.

How is it different from a database view or a data warehouse?

  • Warehouse: stores the data. A semantic layer stores no rows, only definitions of how to compute and combine them.
  • View: fixes one query shape. A semantic layer lets consumers request any allowed combination of metrics and dimensions, and generates the query for them.
  • BI tool model: a Power BI semantic model lives inside Microsoft's tooling, so other tools may not reuse it. Standalone layers such as dbt's and Cube's aim to serve many tools through APIs.

What are the trade-offs?

A semantic layer is one more thing to build and maintain. Someone has to own the definitions and agree on them, which is as much a team process as a technical one. Features and licensing differ by product and change over time, so check the vendor's current documentation before committing to one.

Frequently asked questions

Is a semantic layer the same as a data warehouse?
No. A data warehouse stores the data in tables. A semantic layer sits on top of those tables and holds the definitions of metrics (such as revenue) and dimensions (such as region) that people query. The warehouse holds the rows; the semantic layer holds the agreed meaning of the numbers.
What is the difference between a semantic layer and a semantic model?
In practice the terms overlap. 'Semantic layer' is the general idea, and a 'semantic model' is one concrete artifact of it. Microsoft, for example, describes a Power BI semantic model as a logical description of an analytical domain with metrics and business-friendly terminology. Microsoft renamed the Power BI 'dataset' content type to 'semantic model'.
Do I need a semantic layer?
You need one when the same metric is calculated in more than one place and the results disagree, or when several tools and teams query the same data. For a single dashboard with one author, a view or a saved query is usually enough.
Why do semantic layers come up with AI and LLMs?
An AI tool that writes SQL against raw tables has to guess what 'revenue' means. If it queries governed metric definitions instead, its answers use the same logic as your dashboards. dbt documents this use: Claude and ChatGPT can connect to the dbt Semantic Layer through the dbt MCP server.

Sources