Semantic layer
A semantic layer defines each business metric, what it counts and how to calculate it, in one place that dashboards, reports and AI agents all read from.
Select any words here to ask your Maestro about them.
Your store has one data warehouse. Finance has a dashboard, marketing has a report, and an AI agent writes its own SQL. All three answer "What was October revenue?" How many different numbers come back?
What it is: a layer between the data warehouse and the tools that read it. It's where you write down, once, what each metric means (revenue, active customers, margin) and how it can be sliced (by month, by region). Dashboards, spreadsheets and agents ask for a metric by name, and the layer writes the SQL.
Examples: the dbt Semantic Layer (MetricFlow), Cube, Looker's LookML and Power BI semantic models.
For AI: an AI agent that writes its own SQL guesses what each column means. With a semantic layer it asks for the metric instead: the same KPI you see on the dashboard.
Build one in the course Data Modeling for AI Agents.
How it's used
A metric defined once
models/marts/fct_orders.yml
- models:
- - name: fct_ordersThe dbt model the metrics live on.
- semantic_model:
- enabled: true
- agg_time_dimension: ordered_at
- columns:
- - name: order_id
- entity:
- type: primary
- name: order
- - name: ordered_at
- granularity: day
- dimension:
- type: time
- metrics:
- - name: revenueThe name every tool asks for.
- type: simple
- agg: sum
- marked: expr: amount - refund_amount - tax - shippingThe business rule, written once: the amount minus refunds, tax and shipping.
When to look closer
An agent with direct access to the tables
An agent and the semantic layer
- marked: The warehouse has a semantic layer that defines revenue
Your semantic layer defines revenue. An agent with SQL access answers "What was October revenue?" Which number does it use?
Ask your Maestro about Semantic layer
It answers from the free course page closest to this word, the way it answers while you study.
You: What does "Semantic layer" mean, in plain words?
Your Maestro: I'll explain it with a case of yours: it sticks better than a definition. Which number at work comes out different depending on who calculates it?
Asking about: Answers from the page "How do I build a dashboard people actually use? Start here"
Only this browser keeps what you ask here. How it works
Learn more
Related terms
- Data warehouse
A data warehouse is a database built for analysis: it brings data from many systems into one place, keeps its history and organizes it for queries.
- dbt (data build tool)
dbt (data build tool) turns SQL SELECT queries into tables or views in your data warehouse, runs them in order and tests the results: dbt run builds the models, dbt test checks them.
- Star schema
A star schema arranges data for analysis: a fact table of events, like sales, in the center, joined by keys to dimension tables (customer, product, date) that describe them.
- KPI (key performance indicator)
A KPI is a number a team tracks to know whether it's doing well at what matters most, like monthly sales or orders delivered on time. It only works if it's well defined, so two people who calculate it get the same answer.