Metric Views: Building a Semantic Layer for Business Metrics

    Who this is for:

    Architecture / Concept Overview: Metric Views: Building a Semantic Layer for Business Metrics

    Metric views sit between raw tables and consumption layers, providing a governed definition of what each metric means and how it should be calculated.

    %%{init: {"theme":"base","themeVariables":{"background":"#0B0E14","primaryTextColor":"#E0E6ED","lineColor":"#5D6470","darkMode":true,"primaryColor":"#2E4A4A","secondaryColor":"#374151","secondaryTextColor":"#E0E6ED","tertiaryColor":"#111827","tertiaryTextColor":"#E0E6ED","edgeLabelBackground":"#1f2937"}}}%% flowchart LR classDef source fill:#3F4B59,stroke:#9CA3AF,stroke-width:2px,rx:8,ry:8,color:#E0E6ED classDef ingestion fill:#5A4B36,stroke:#C9A86B,stroke-width:2px,rx:8,ry:8,color:#E0E6ED classDef processing fill:#535072,stroke:#8E82B4,stroke-width:2px,rx:8,ry:8,color:#E0E6ED classDef storage fill:#2E4A4A,stroke:#5FAFA8,stroke-width:2px,rx:8,ry:8,color:#E0E6ED classDef serving fill:#3D5550,stroke:#6BB7AA,stroke-width:2px,rx:8,ry:8,color:#E0E6ED classDef governance fill:#5A3F52,stroke:#C28BB0,stroke-width:2px,rx:8,ry:8,color:#E0E6ED RAW[Raw / Bronze Tables] --> CURATED[Silver / Gold Tables] CURATED --> MV[Metric Views<br/>Semantic Layer] MV --> DASH[AI/BI Dashboards] MV --> SQL[SQL Queries] MV --> BI[BI Tools] RAW:::source CURATED:::storage MV:::governance DASH:::serving SQL:::serving BI:::serving

    *Figure 1 — Metric views provide a consistent semantic layer between curated tables and all consumption channels.*

    A metric view is composed of a source table, dimensions for slicing, and measures that encode business logic.

    %%{init: {"theme":"base","themeVariables":{"background":"#0B0E14","primaryTextColor":"#E0E6ED","lineColor":"#5D6470","darkMode":true,"primaryColor":"#2E4A4A","secondaryColor":"#374151","secondaryTextColor":"#E0E6ED","tertiaryColor":"#111827","tertiaryTextColor":"#E0E6ED","edgeLabelBackground":"#1f2937"}}}%% graph TD classDef source fill:#3F4B59,stroke:#9CA3AF,stroke-width:2px,rx:8,ry:8,color:#E0E6ED classDef ingestion fill:#5A4B36,stroke:#C9A86B,stroke-width:2px,rx:8,ry:8,color:#E0E6ED classDef processing fill:#535072,stroke:#8E82B4,stroke-width:2px,rx:8,ry:8,color:#E0E6ED classDef storage fill:#2E4A4A,stroke:#5FAFA8,stroke-width:2px,rx:8,ry:8,color:#E0E6ED classDef serving fill:#3D5550,stroke:#6BB7AA,stroke-width:2px,rx:8,ry:8,color:#E0E6ED classDef governance fill:#5A3F52,stroke:#C28BB0,stroke-width:2px,rx:8,ry:8,color:#E0E6ED MV[Metric View] --> SRC[Source Table<br/>e.g. gold.sales.orders] MV --> DIM[Dimensions<br/>region · product · channel] MV --> MEAS[Measures<br/>revenue · order_count · avg_order_value] MV --> FILT[Default Filters<br/>status = 'completed'] MV:::governance SRC:::storage DIM:::processing MEAS:::serving FILT:::ingestion

    *Figure 2 — Internal structure of a metric view: source table, dimensions, measures, and optional default filters.*

    Key Terms

    Prerequisites and Setup

    • Unity Catalog enabled with a metastore assigned to the workspace
    • CREATE METRIC VIEW privilege on the target schema
    • Source tables registered in Unity Catalog
    • A SQL warehouse to execute metric view queries

    Step-by-Step Implementation

      Configuration Reference

      Metric Views: Building a Semantic Layer for Business Metrics configuration options
      PropertyDescriptionExample
      COMMENTDescription of the metric view, dimension, or measure'Total revenue from completed orders'
      WITH MEASURESBlock defining aggregate calculationsSUM(total_amount)
      WITH DIMENSIONSBlock defining slice-and-dice columnsregion AS DIMENSION
      WITH FILTERSDefault filter applied unless overridden at query timestatus = 'completed'
      CREATE OR REPLACEReplaces the metric view definition in placeUse for iterative development

      Monitoring, Cost, and Security Considerations

      Common Pitfalls and Recommended Patterns

        Frequently Asked Questions