Course contentsShow
← Data Engineering
Lesson 350 of 8255. Batch ETL/ELT Pipelines with dbtFree lesson

Exposing Data Products through Semantic Layers

Define dbt metrics and exposures to connect your transformed data models directly to downstream BI tools for enterprise-wide visibility.

In this lesson, you will learn how to transition from simply building tables to creating "Data Products" by using dbt Metrics and Exposures to link your warehouse directly to business intelligence tools.

The Semantic Layer: Beyond Raw Tables

As a data engineer, your models (tables/views) are often just raw ingredients for stakeholders. If an analyst wants to calculate "Monthly Recurring Revenue," they shouldn't have to guess which join logic or filter criteria you used. A Semantic Layer acts as the single source of truth, where business logic (metrics) is defined once in code rather than scattered across a dozen Tableau or PowerBI dashboards.

Defining Metrics in dbt

In dbt, you define metrics in YAML files. This allows you to standardize calculations. For example, instead of letting users write their own sum(amount) logic, you define a formal metric:

metrics:
  - name: total_revenue
    label: Total Revenue
    model: ref('fct_orders')
    calculation: sum
    column: amount
    timestamp: order_date
    time_grains: [day, month, year]

By defining this, any tool connected to your dbt project via a semantic layer driver knows exactly how to calculate "Total Revenue" without the user writing a single line of complex SQL.

Connecting to BI via Exposures

While metrics define what the data is, Exposures tell the world who is using it. An exposure is a dbt object that represents a downstream dashboard, a report, or even a machine learning model. By defining an exposure, you create a direct link in your dbt lineage graph between your transformed data and the final BI asset.

exposures:
  - name: sales_executive_dashboard
    label: Sales Executive Dashboard
    type: dashboard
    depends_on:
      - ref('fct_orders')
      - metric('total_revenue')
    owner:
      name: Data Team

This ensures that if you change a column name in fct_orders, dbt will warn you that your sales_executive_dashboard is about to break. This turns your warehouse into a robust, observable data product that enterprise users can trust.

Key Takeaway: By defining metrics and exposures, you transform static tables into documented, standardized data products that bridge the gap between technical pipelines and business decision-making.