Databricks has introduced a powerful featureโMetric Viewsโthat transforms how organizations define, manage, and consume business metrics. Whether you're a data analyst, engineer, or business stakeholder, Metric Views offer a unified, governed, and reusable way to model KPIs across your reporting ecosystem.
What Are Metric Views?
Metric Views are centralized definitions of business metrics that abstract complex logic into reusable components. Registered in Unity Catalog, these views allow teams to define KPIs and use them consistently across dashboards, alerts, and data apps like Genie spaces.

Key Benefits:
- Consistency: Define metrics once and reuse them across tools.
- Governance: Centralized control via Unity Catalog.
- Scalability: Supports complex schemas like star and snowflake.
- Flexibility: Queryable via SQL, usable in BI tools.
Core Components of a Metric View
Metric Views are defined in YAML format and include:
Component | Description |
Source | Table, view, or SQL query that feeds the metric view |
Joins | Optional joins for star/snowflake schemas |
Filter | Optional condition to restrict data (e.g., date filters) |
Dimensions | Categorical attributes for grouping (e.g., region, product category) |
Measures | Array of aggregated expressions representing business metrics. (e.g., SUM, COUNT) |
Metric Views vs. Standard Views
Feature | Metric View | Standard View |
Purpose | Centralized KPI definition | Specific business question |
Format | YAML | SQL |
Governance | Unity Catalog | Schema-level |
Reusability | High | Limited |
Schema Support | Star & Snowflake | Typically flat or star |
- Problem Statement
The Challenge of Metric Fragmentation
In most organizations, metrics are defined in multiple places:
- SQL queries embedded in dashboards
- Python scripts in notebooks
- Excel sheets shared across departments
This leads to:
- Inconsistent definitions (e.g., โactive usersโ varies by team)
- Redundant logic across tools
- Increased maintenance overhead
- Risk of misinterpretation in decision-making
Why It Matters
When metrics are fragmented:
- Business decisions may be based on conflicting data.
- Analysts spend time reconciling definitions instead of generating insights.
- Scaling analytics across teams becomes difficult.
Databricksโ Metric Views solve this by centralizing metric logic in a governed, reusable format.
- Implementation with Practical Examples / Use Cases
How to Create a Metric View
You can define Metric Views using either SQL or the Catalog Explorer UI. Here's a simplified workflow:
- Choose a Data Source: Table, view, or SQL query.
- Define Dimensions and Measures: Use YAML to specify logic.
- Register in Unity Catalog: Assign to a schema and catalog.
- Set Permissions: Ensure downstream users have access.
How Metric Views Work
Metric Views are defined using YAML, a human-readable format that specifies:
- The data source (table/view)
- Optional filters
- Dimensions (grouping attributes)
- Measures (aggregated KPIs)
These definitions are registered in Unity Catalog, making them accessible across SQL, dashboards, and Genie spaces.
Example YAML Snippet:
version: 0.1
source: samples.tpch.orders
filter: o_orderdate > '1990-01-01'
dimensions:
- name: Order Month
expr: DATE_TRUNC('MONTH', o_orderdate)
- name: Order Status
expr: CASE
WHEN o_orderstatus = 'O' then 'Open'
WHEN o_orderstatus = 'P' then 'Processing'
WHEN o_orderstatus = 'F' then 'Fulfilled'
END
- name: Order Priority
expr: SPLIT(o_orderpriority, '-')[1]
measures:
- name: Order Count
expr: COUNT(1)
- name: Total Revenue
expr: SUM(o_totalprice)
- name: Total Revenue per Customer
expr: SUM(o_totalprice) / COUNT(DISTINCT o_custkey)
- name: Total Revenue for Open Orders
expr: SUM(o_totalprice) FILTER (WHERE o_orderstatus='O')
Query a metric view
To query a metric view, you must be attached to a SQL warehouse or other compute resource running Databricks Runtime 16.4 or above.
The following sample query evaluates the three listed measures and aggregates over Order Month and Order Status. It returns results sorted by Order Month.
All measures must be wrapped in the MEASURE function.
SELECT `Order Month`, `Order Status`,
MEASURE(`Order Count`),
MEASURE(`Total Revenue`),
MEASURE(`Total Revenue per Customer`)
FROM orders_metric_view
GROUP BY ALL
ORDER BY 1 ASC
Use Case 1: Sales Dashboard
Define metrics like:
- Total Revenue

- Orders per Region

- Revenue per Customer

Use the same Metric View across:
- Genie spaces
- BI dashboards
- SQL queries
Use Case 2: Operational Alerts
Set up alerts when:
- Daily revenue drops below threshold
- Order fulfillment rate falls below SLA

Metric Views ensure the logic behind these alerts is consistent and governed.
Access Control & Security
Metric Views inherit Unity Catalogโs robust access controls. You can manage privileges at the catalog, schema, and view level, ensuring secure and compliant data usage.
- Key Features / Benefits
Feature | Benefit |
Centralized Definitions | Define KPIs once, reuse everywhere |
YAML Scripting | Human-readable, version-controlled metric logic |
Unity Catalog Integration | Governed access and discoverability |
Schema Support | Works with star and snowflake schemas |
SQL Compatibility | Query Metric Views directly in notebooks or dashboards |
Reusability | Use across Genie spaces, BI tools, and alerts |
Governance | Role-based access control via Unity Catalog |
Metric Views reduce duplication, improve trust in data, and accelerate insight generation.
5: Pre-Requisites & Conclusion
Pre-Requisites
To create and use Metric Views, ensure:
- You have SELECT privileges on the source table/view
- You have CREATE TABLE and USE SCHEMA privileges
- You have USE CATALOG privilege
- Youโre using Databricks Runtime 16.4 or later
- Youโre working within a Unity Catalog-enabled workspace
Conclusion
Metric Views in Databricks offer a powerful solution to one of the most persistent problems in analytics: inconsistent metric definitions. By centralizing KPI logic in YAML and governing it through Unity Catalog, teams can ensure consistency, scalability, and trust in their data.
Whether you're building dashboards, triggering alerts, or scaling analytics across departments, Metric Views provide the foundation for unified, reliable business metrics.
Ready to get started? Explore the official Databricks documentation and YAML reference guide to build your first Metric View today.
@VasaviKS