Databricks Metric View Parameters: One Definition, Many Uses
Databricks metric view parameters let one metric view definition return different results for different values, such as a discount rate or a start date. This guide adds parameters to a metric view, calls it by name, by position and with defaults, checks where the values land in the query plan, and passes a value from a dashboard with a value list. You also see the exact errors for the rules that…
Databricks metric view parameters enable a single metric view definition to return various results based on different input values, such as a discount rate or a start date. This guide explains how to add parameters to a metric view, call it by name, by position, or with default values, and pass values from a dashboard.
A parameter in Databricks is a named value that a caller provides when querying a metric view. The definition incorporates the parameter in a measure, a filter, the source, or a join, allowing one definition to produce multiple variants. Parameters are typically available since the November 13, 2026 release.
To query a metric view with parameters, Databricks Runtime 18.2 or later is required on a SQL warehouse or other compute. Querying the view functions similarly to a table-valued function, with values passed by name, position, or without any value to utilize defaults.
Each parameter comprises a name, data type (double, int, string, or date), and an optional default value. A dashboard can pass a value to a parameter using a filter widget.
You can call a metric view like a table in four ways - by name, by position, with defaults, or from a dashboard. When using parameters, you modify the metric within the definition (in measures, filters, or joins) rather than generating separate metric views for each variant. This approach is more efficient than creating separate views for each scenario.
Metric view parameters are ideal when callers require multiple variants of the same metric, such as different discount scenarios or cutoff dates. However, if a caller only needs to slice results, a normal dimension is more appropriate. Metric views with parameters cannot be materialized, so use a view without parameters when materialized aggregates are necessary.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to