# Semantic layer

> One place that defines a company's metrics, so every tool computes them the same way.

- Level: Advanced
- Topics: Data
- URL: https://tidbit.legios.com.ar/semantic-layer/
- In Spanish: [Capa semántica](https://tidbit.legios.com.ar/es/semantic-layer/)

A **semantic layer** sits between the raw tables of a data warehouse and the tools people use to ask questions. In it, the data team defines business concepts once, in code: what "revenue" means (net of refunds? with tax?), what an "active customer" is, how tables join, which time zone a "day" uses. Dashboards, spreadsheets and other tools then ask for `revenue by month` and the layer writes the correct SQL for them.

The problem it solves is painfully common: marketing's dashboard says 12,400 active customers, finance's spreadsheet says 11,900, and both are "right" because each one encoded its own definition in its own tool. When the logic lives in one layer instead of being copied into every report, a definition changes in one place and every consumer gets the new version. It is the same idea as a function in programming: write the rule once, call it everywhere.

Examples include the dbt Semantic Layer, Cube, LookML in Looker and AtScale. It has become more important with AI: when a language model answers "how did revenue do last quarter?", pointing it at well-defined metrics is far more reliable than letting it guess joins and filters from hundreds of raw tables. A semantic layer is often paired with data governance, since it is where the official meaning of each number is written down.

## An analogy

The official dictionary of a language. Without it, every town ends up using "tea" or "dinner" to mean slightly different things; with it, everyone looks up the same definition, and arguments are about the facts instead of the words.

## Keep in mind

- Defines metrics, dimensions and joins once, in code, between the warehouse and the tools.
- Ends the "why do these two dashboards disagree?" problem.
- Tools ask for a metric by name and the layer generates the SQL.
- Gives AI assistants a reliable vocabulary instead of raw tables.

## Go deeper

- [Semantic layer on Wikipedia](https://en.wikipedia.org/wiki/Semantic_layer)
- [dbt Semantic Layer (official docs)](https://docs.getdbt.com/docs/use-dbt-semantic-layer/dbt-sl)

## Related terms

- [Data warehouse](https://tidbit.legios.com.ar/data-warehouse/): A database built for analysis: years of history, from many sources, in one place.
- [Dashboard](https://tidbit.legios.com.ar/dashboard/): One screen of charts and numbers that shows how something is doing at a glance.
- [Spreadsheet vs database](https://tidbit.legios.com.ar/spreadsheet-vs-database/): Why a company that runs on Excel eventually needs a real database.
- [SQL](https://tidbit.legios.com.ar/sql/): The language you use to ask a database questions.
- [Artificial intelligence](https://tidbit.legios.com.ar/artificial-intelligence/): Getting computers to do things that, until recently, only people could do.
- [LLM](https://tidbit.legios.com.ar/llm/): A neural network trained on huge amounts of text to predict the next word.
- [Data governance](https://tidbit.legios.com.ar/data-governance/): The rules and roles that decide who owns data, who can use it and how it is kept right.
