Blog › How Databricks Metric Views Keep Every KPI Consistent
Context management

How Databricks Metric Views Keep Every KPI Consistent

OvalEdge Team

Dec 4, 2026 • 22 min read
Book a Demo
✦ Quick Answer

How do Databricks metric views work?

 

Databricks metric views are Unity Catalog objects that define each business metric once, so every dashboard and Genie answer returns the same number. Each view is written in YAML and names a source table, its joins, and the measures and fields people query. Users call a measure with the MEASURE() function, and connected BI tools can query the views too.

 

Writing the YAML is quick. Choosing the formula takes longer, especially when Finance and Sales calculate the same KPI differently.

 

OvalEdge's Source Code Intelligence surfaces the competing formulas across SQL and BI tools, and Lingo helps each owner confirm which version a metric view should encode. Find every version of your KPIs

In her first week, a new analyst got what looked like an easy request. The board deck needed the number of active customers. She found the metric in three dashboards, and each one counted customers differently. One excluded trial accounts. Another counted anyone who logged in that quarter. The third had no notes at all.

She spent the rest of the week asking around for the right formula.

Databricks metric views stop this drift from coming back once a formula is agreed. Each key performance indicator (KPI) is defined once in Unity Catalog. Every dashboard and Genie answer then reads that same definition.

The sections below cover how to build and use metric views. They also cover how to agree on the formula behind each one.

What are Databricks metric views and how do they work?

Databricks metric views are Unity Catalog objects that store each business metric's definition in one governed place. Every view is written in YAML. It describes the source data and the calculations people can run on it. Users then query those calculations with the MEASURE() function.

The key design choice is how metric views handle aggregation. A standard view fixes its groupings when someone creates it. A metric view keeps each measure separate from the dimensions used to slice it, as the Databricks metric views documentation explains. At query time, Databricks computes the measure correctly for whatever grouping the query asks for.

This design matters most for ratios and distinct counts. Adding up pre-aggregated rows gives wrong answers for both, so a metric view computes them fresh for each grouping. Revenue per customer stays accurate whether someone groups it by region or by month.

Once registered, a metric view works like any other Unity Catalog asset. It follows the same permission model as other views, and several Databricks tools can read it:

  • SQL editors and notebooks

  • AI/BI dashboards and alerts

  • Genie Agents

Why the same KPI shows different numbers across dashboards and Genie

The same KPI shows different numbers when its formula lives in more than one place. A dashboard may calculate revenue one way while a notebook calculates it another way. Each copy starts out identical and drifts as people add filters or exclusions.

Drift like this is common across data teams.

The  Modern Data Report 2026 survey by The Modern Data Company found that 84% of more than 540 data leaders and practitioners encounter conflicting versions of the same metric, and over a third face it regularly.

The data pipeline is rarely at fault. Jobs run on time and tables refresh, yet the numbers still disagree. The real cause is metric logic scattered across downstream tools.

AI assistants add one more copy. When Genie answers from raw tables, it writes its own SQL for each question. Without a shared definition, its answer can contradict the finance report on the same topic.

For years, agreed meanings sat in a business glossary while each tool kept its own formula. Metric views move the formula into Unity Catalog, right next to the data. The new analyst's three versions of active customers came from exactly this kind of drift.

Unity Catalog metric views vs standard and materialized views

Metric views sit alongside two older view types in Databricks, and each one solves a different problem. The comparison below shows where they differ.

 

Standard view

Materialized view

Metric view

What it stores

The query logic

Precomputed results in a Delta table

Measures, dimensions, and joins in YAML

How aggregation works

Fixed when the view is created

Fixed by the defining query

Computed at query time for any grouping

Best suited for

Answering one specific question

Speeding up expensive, repeated queries

KPIs that many tools reuse

How users query it

Standard SELECT

Standard SELECT

MEASURE() for each measure

Data freshness

Reads source data on every query

As fresh as its last refresh

Reads source data, or precomputed results when available

The materialized view comparison causes the most confusion. A materialized view is a Delta table that stores precomputed query results. Metric views can use materialized views behind the scenes through a feature called materialization, which routes matching queries to precomputed results. In practice, the two often work together.

With the differences clear, the next step is building a metric view from scratch.

How to build a Databricks metric view in YAML

OvalEdge Blogs 1 (16) (1)

A Databricks metric view is built by writing a YAML definition and registering it in Unity Catalog. The definition names a source table and the joins it needs. It then declares the measures people calculate and the fields they group by. Every key follows the  Databricks metric view YAML reference, so one view reads much like the next.

1. Check prerequisites and permissions

A few requirements need to be in place before writing any YAML. Most failed metric view creations trace back to one of these:

  • A workspace enabled for Unity Catalog

  • A SQL warehouse, or compute running Databricks Runtime 16.4 or above

  • SELECT permission on the source table

  • CREATE TABLE and USE SCHEMA permissions on the target schema

Newer features need newer runtimes. One-to-many joins, for example, require Databricks Runtime 18.1. A SQL warehouse updates automatically, so the runtime matters mainly on clusters.

2. Set the source table and filters

Every metric view starts from one source, usually a fact table such as orders or transactions. The source can also be a view, another metric view, or a SQL query. An optional filter limits which rows the view reads, such as orders placed after a given date.

The source choice shapes every number the view returns. Checking the table's column-level lineage first confirms where its data comes from and what feeds it. A well-understood source makes the rest of the definition easier to trust.

3. Add joins to dimension tables

Joins bring in descriptive attributes, such as customer segment or region, from dimension tables. Metric views support star schemas, where the fact table joins directly to each dimension. They also support snowflake schemas, where one dimension joins to another through nested joins.

Each join assumes a many-to-one relationship by default, with many orders to one customer. This is where most wrong numbers start. If a join meets several matching rows, the engine keeps only the first match. Joining two fact tables directly also produces incorrect totals. Modeling joins as fact-to-dimension relationships prevents silent errors in every dashboard downstream.

OvalEdge expert insight: Before adding a join, confirm the dimension table really has one row per key. When it doesn't, the metric view and the legacy dashboard will disagree, and the view will look wrong even when its formula is right.

4. Declare measures and dimensions

Dimensions are the attributes people group and filter by. The current YAML specification calls them fields, though the older dimensions keyword still works. Measures are the calculations, and every measure must use an aggregate function such as SUM or COUNT.

Here's how a simple order metrics view comes together, using the sample TPC-H data that ships with every Databricks workspace:

Part of the definition

What the example sets

Version

YAML specification 1.1

Comment

Order KPIs shared by Finance and Sales

Source

The sample orders table

Filter

Orders placed from 1995 onward

Join

The customer table, matched on customer key

Fields

Order month and market segment from the customer table

Measures

Total revenue (sum of order prices), unique customers (distinct count of customers), and revenue per customer (total revenue divided by unique customers)

Here's the full YAML for that view:

version: 1.1

comment: "Order KPIs shared by Finance and Sales"

source: samples.tpch.orders

filter: o_orderdate >= '1995-01-01'

 

joins:

- name: customer

source: samples.tpch.customer

'on': o_custkey = c_custkey

 

fields:

- name: order_month

expr: DATE_TRUNC('MONTH', o_orderdate)

display_name: 'Order Month'

- name: market_segment

expr: customer.c_mktsegment

display_name: 'Market Segment'

 

measures:

- name: total_revenue

expr: SUM(o_totalprice)

display_name: 'Total Revenue'

- name: unique_customers

expr: COUNT(DISTINCT o_custkey)

display_name: 'Unique Customers'

- name: revenue_per_customer

expr: MEASURE(total_revenue) / MEASURE(unique_customers)

display_name: 'Revenue per Customer'

The last measure builds on the two before it. Defining simple measures first and composing ratios from them keeps each formula short and easy to review.

5. Register the view with SQL or Catalog Explorer

Registering saves the definition as a Unity Catalog object others can query. In SQL, the YAML goes inside a CREATE VIEW statement with the WITH METRICS LANGUAGE YAML clause.

For the view above, the statement looks like this:

CREATE OR REPLACE VIEW main.sales.order_metrics

WITH METRICS

LANGUAGE YAML

AS $$

-- paste the YAML from step 4 here

$$;

Catalog Explorer offers a visual route instead:

  1. Open Catalog Explorer and choose the target catalog and schema.

  2. Click Create and select Metric view.

  3. Enter a name, then write or paste the YAML in the editor.

  4. Save the view, which validates the YAML before registering it.

Both routes produce the same object, governed by the same Unity Catalog permissions. Once the view exists, the next question is how people and tools query it.

How to query Databricks metric views in dashboards, Genie, and BI tools

Databricks metric views are queried with SQL, and every measure is wrapped in the MEASURE() function. AI/BI dashboards and Genie read metric views directly, so their numbers follow the YAML definition. External BI tools connect through SQL, though each tool needs its own setup.

Call measures with the MEASURE() function

A metric view query looks much like a standard aggregate query. It selects the fields to group by and wraps each measure in MEASURE(). For example, this query returns revenue per customer by market segment:

SELECT

market_segment,

MEASURE(revenue_per_customer) AS revenue_per_customer

FROM main.sales.order_metrics

GROUP BY market_segment;

Databricks computes the ratio correctly at that grain. The same measure grouped by order month returns accurate monthly figures, with no extra logic in the query.

One habit takes some getting used to: SELECT * fails on a metric view, because every measure has to be named inside MEASURE(). On Databricks Runtime 18.1 and above, AGG() works as a shorter alias. Once analysts get used to listing columns explicitly, querying feels familiar.

Use metric views in AI/BI dashboards and Genie

AI/BI dashboards treat a metric view as a dataset. Its fields and measures appear in the visualization builder, so every chart draws on the same definitions. Dashboard authors can also build local metric views inside a single dashboard without publishing to Unity Catalog. Local views suit exploration, while KPIs shared across dashboards belong in Unity Catalog.

Genie gains even more. When a Genie Agent includes a metric view, Genie uses the defined measure for any question about that KPI. Agent metadata in YAML version 1.1 helps Genie match plain-English questions to the right measure:

  • Synonyms: Alternative names, such as "sales" for total revenue

  • Display names: Business-friendly labels for fields and measures

  • Formats: Rules that show values as currency or percentages

With this metadata in place, a question about sales returns the same total revenue figure the finance dashboard shows.

OvalEdge expert insight: Synonyms help Genie match questions, but a broad synonym can blur two valid versions of a KPI. Give each approved version its own measure and name, and keep each synonym specific to one version.

Query metric views from Power BI, Tableau, and other BI tools through SQL

External BI tools reach metric views through SQL-based connections. Databricks documents  several connection patterns for external BI tools, each suited to a different setup:

Pattern

When it fits

Custom SQL with MEASURE()

The tool can send its own SQL to Databricks, which most tools support

Wrapper view

Authors want a standard view that hides the MEASURE() logic from BI users

BI compatibility mode

The tool generates standard aggregations such as SUM, and Databricks rewrites them

Built-in partner integration

The vendor supports metric views natively, so measures appear without custom SQL

Power BI needs the most care right now. In April 2026, Microsoft removed BI compatibility mode from the Power BI connector for Databricks, and reports using that option stopped working. Databricks now recommends the connector's Native query option with MEASURE() in DirectQuery mode. Publishing metric views to Power BI as semantic models is also in private preview.

Practitioners have welcomed metric views coming back to Power BI as semantic models, while flagging practical limits such as one-way sync and security changes in Import mode.

Tabular Editor offers another route. Its Semantic Bridge, available in the Enterprise edition of Tabular Editor 3, converts a Databricks metric view into a Power BI semantic model.

Organizations that report in several tools also need to see which reports rely on which metrics. A data catalog that spans Databricks and BI tools makes those dependencies visible before a definition changes. With consistency handled, query speed comes next.

See which reports depend on each metric view

Use OvalEdge's Enterprise Context Graph to trace every Databricks and BI report back to the metric definition it uses, so you can check the impact before a definition changes.

Trace your metric dependencies →

Speed up queries with materialization

By default, a metric view computes every query from its source tables, including all joins and aggregations. On large tables behind busy dashboards, that can slow responses. Materialization, generally available since July 2026, precomputes selected aggregations as materialized views.

A managed Lakeflow pipeline refreshes those materialized views on a schedule set in the YAML. At query time, the optimizer reads a precomputed result when one matches the query. Otherwise, it falls back to source data, so answers stay correct either way. Materialization requires Databricks Runtime 17.3 or above, with serverless compute enabled in the workspace.

A practical starting point is the field and measure combinations the busiest dashboards use. Fast, consistent queries still depend on the formula inside each view, and agreeing on that formula takes the most care.

How to agree on the metric definitions your metric views encode

OvalEdge Blogs 1 (17)

Agreeing on metric definitions starts with tracing every formula already in use. Each business owner then confirms which version applies to which purpose. Writing the YAML is the quick part of building a metric view. Choosing the formula takes longer, especially when Finance and Sales each calculate the same KPI their own way.

Databricks' own data team treated this agreement as part of the build. When it moved core metrics into metric views for Genie, it pushed them through an internal metric store that enforces consistency across queries. Unity Catalog governs and serves whatever definition goes into the view. The decision about which definition is right still comes from people. Governance is what turns that decision into numbers people trust.

According to the 2026 State of Data Integrity and AI Readiness report from Precisely and Drexel LeBow, 71% of organizations with a data governance program report high trust in their data, compared with 50% of those without one.

OvalEdge expert insight: A metric view is only as trustworthy as the agreement behind it. The smoothest builds start with a short list of disputed KPIs and a named owner for each one.

1. Find every version of the KPI already in use

The new analyst's three versions of active customers each lived in a different dashboard, built on different SQL. Finding them by hand means reading the queries behind every report and tracking down whoever wrote them. On a large data estate, versions get missed.

OvalEdge shortens that search. Its Source Code Intelligence reads the logic behind each asset, including:

  • SQL and stored procedures

  • Notebooks

  • Calculations inside BI tools

The result shows each competing formula side by side, along with the tables it draws on. Owners can then compare the versions directly before anyone writes YAML. Finding the versions is half the work, and deciding what each one is for is the other half.

2. Confirm which definition serves which purpose

Not every difference between versions is a mistake. The count that excludes trial accounts may be right for board revenue reporting. The login-based count may be right for tracking product engagement. Both are valid, as long as each one has a clear name and purpose.

Lingo, OvalEdge's agent for glossary curation, turns each version into a governed business definition with a named purpose and owner. Where a rule is unclear, Question Wall sends a focused question to the right person. For example, the question might be "Which active customer definition applies to board reporting?" The owner answers once, on the asset itself.

Approved definitions then connect to their lineage, owners, and dependent reports in OvalEdge's Enterprise Context Graph. From there, the data team encodes each version as its own measure, such as active customers (billing) and active customers (engagement). Comments and synonyms carry the agreed meaning into the metric view. That helps Genie match each question to the version its owner approved.

Rules change over time, and lineage shows which metric views and dashboards depend on each definition. The owner revalidates the definition, and the data team updates the view before Genie answers from the old rule. Every metric view then encodes a definition the business has agreed on, and Genie answers with that number.

4.7/5 on  Gartner Peer Insights | 337% ROI (Forrester TEI)

Conclusion

Databricks metric views give dashboards and Genie one governed definition for each KPI. Building one follows a clear pattern, and a few choices decide whether the numbers hold up:

  • Model joins as many-to-one, fact-to-dimension relationships

  • Compose ratios from simple measures

  • Match the BI connection pattern to each tool, especially Power BI

  • Settle the formula with its owner before writing YAML

Which KPIs carry more than one formula today? Does each version have a named owner and purpose?

Metric views define each KPI once. OvalEdge helps the business agree on what that definition should be, and its Enterprise Context Graph keeps each one connected to lineage and owners.

Book a demo to see how OvalEdge finds competing KPI formulas across SQL and BI tools, gets each version confirmed by its owner, and connects it in its Enterprise Context Graph.

Frequently Asked Questions

Everything you need to know about this topic

Are Databricks metric views open source?
Not fully yet, though Databricks is moving in that direction. It has announced it is open-sourcing metric views in Apache Spark and has joined the Open Semantic Interchange initiative. Both moves aim to make metric definitions portable beyond a single vendor's platform. 
Why does SELECT * fail on a metric view?
SELECT * fails because every measure in a metric view has to be called through the MEASURE() function. A query must list each field and wrap each measure explicitly. On Databricks Runtime 18.1 and above, AGG() works as a shorter alias for MEASURE(). 
Which Databricks Runtime version do metric views need?
Metric views need Databricks Runtime 16.4 or above. Some features need newer versions. Materialization requires 17.3, and one-to-many joins require 18.1. SQL warehouses update automatically, so the runtime mainly matters when queries run on clusters. 
Who can edit a metric view?
By default, only the owner of a metric view can edit its definition. Anyone with SELECT permission can query the view and browse its details in Catalog Explorer. Databricks also supports collaborative editing, which lets more people maintain a shared definition. 
Can metric views be shared outside a workspace?
Yes. Sharing metric views through OpenSharing became generally available in September 2026. Providers add a metric view to a share, and recipients query it with MEASURE() on serverless compute. The definition travels with the share, so every recipient calculates the KPI the same way. 
Do metric views replace semantic models in BI tools?
Metric views can become the central definition, but BI semantic models often stay in place for now. Native Power BI support is still in private preview, so many organizations keep a Power BI model alongside them. Genie Code can import an existing Tableau or Power BI model and replicate it as a metric view. 
What is the difference between a metric view and a materialized view in Databricks?
A materialized view stores precomputed query results in a Delta table. A metric view stores the KPI definition and computes it at query time for any grouping. The two can work together: materialization lets a metric view read precomputed results when they match the query. 

Ready to Transform your Data?

See how OvalEdge helps teams bring ownership, policies, lineage, quality, and trusted data access into one connected governance platform.

Book a demo
Deep-dive whitepapers on modern data governance and agentic analytics
Download Whitepapers

OvalEdge Team

The OvalEdge Team collaborates with industry experts, practitioners, and business leaders to create practical content on AI, context, and data governance. Our goal is to help organizations navigate the evolving data and AI space with confidence.

OvalEdge Recognized as a Leader in Data Governance Solutions

SPARK Matrix™: Data Governance Solution, 2025
Final_2025_SPARK Matrix_Data Governance Solutions_QKS GroupOvalEdge 1
Total Economic Impact™ (TEI) Study commissioned by OvalEdge: ROI of 337%

“Reference customers have repeatedly mentioned the great customer service they receive along with the support for their custom requirements, facilitating time to value. OvalEdge fits well with organizations prioritizing business user empowerment within their data governance strategy.”

Named an Overall Leader in Data Catalogs & Metadata Management

“Reference customers have repeatedly mentioned the great customer service they receive along with the support for their custom requirements, facilitating time to value. OvalEdge fits well with organizations prioritizing business user empowerment within their data governance strategy.”

Recognized as a Niche Player in the 2025 Gartner® Magic Quadrant™ for Data and Analytics Governance Platforms

Gartner, Magic Quadrant for Data and Analytics Governance Platforms, January 2025

Gartner does not endorse any vendor, product or service depicted in its research publications, and does not advise technology users to select only those vendors with the highest ratings or other designation. Gartner research publications consist of the opinions of Gartner’s research organization and should not be construed as statements of fact. Gartner disclaims all warranties, expressed or implied, with respect to this research, including any warranties of merchantability or fitness for a particular purpose. 

GARTNER and MAGIC QUADRANT are registered trademarks of Gartner, Inc. and/or its affiliates in the U.S. and internationally and are used herein with permission. All rights reserved.