<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Metric Views + Window Functions not supported in Warehousing &amp; Analytics</title>
    <link>https://community.databricks.com/t5/warehousing-analytics/metric-views-window-functions-not-supported/m-p/150199#M2523</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/217270"&gt;@wrosa&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;The error you are seeing (METRIC_VIEW_WINDOW_FUNCTION_NOT_SUPPORTED) is expected behavior. Metric views do not allow raw SQL window functions like SUM(...) OVER() directly in a measure's expr definition. This is by design because metric views use their own declarative window specification in the YAML definition rather than inline SQL window syntax.&lt;/P&gt;
&lt;P&gt;WHAT IS HAPPENING&lt;/P&gt;
&lt;P&gt;When you define a measure as:&lt;/P&gt;
&lt;P&gt;- name: Sales net Total&lt;BR /&gt;expr: SUM(MEASURE(`Sales net`)) OVER()&lt;/P&gt;
&lt;P&gt;The metric view engine rejects this because OVER() is standard SQL window function syntax, which is not permitted inside a measure expression. Measure expressions in metric views must be aggregate expressions (like SUM(), COUNT(), AVG(), etc.), optionally with FILTER clauses or arithmetic, but not SQL window functions.&lt;/P&gt;
&lt;P&gt;HOW TO ACHIEVE THE SAME RESULT&lt;/P&gt;
&lt;P&gt;You have two options depending on what you need.&lt;/P&gt;
&lt;P&gt;OPTION 1: USE THE METRIC VIEW WINDOW MEASURE YAML SYNTAX&lt;/P&gt;
&lt;P&gt;Metric views support "window measures" as a declarative feature. Instead of writing OVER() in the expr, you define a window block in the YAML. For example, if you want a grand total of Sales net across all rows, you would define it like this:&lt;/P&gt;
&lt;P&gt;measures:&lt;BR /&gt;- name: Sales net&lt;BR /&gt;expr: SUM(sales_net_column)&lt;BR /&gt;- name: Sales net Total&lt;BR /&gt;expr: SUM(sales_net_column)&lt;BR /&gt;window:&lt;BR /&gt;- order: &amp;lt;some_dimension&amp;gt;&lt;BR /&gt;range: all&lt;BR /&gt;semiadditive: last&lt;/P&gt;
&lt;P&gt;The "range: all" specification gives you the equivalent of OVER() (the entire dataset). The "order" field must reference one of your defined dimensions, and "semiadditive" controls how the value is summarized when that order dimension is not in the GROUP BY of your query.&lt;/P&gt;
&lt;P&gt;Here is a more concrete example. If you have a date dimension:&lt;/P&gt;
&lt;P&gt;dimensions:&lt;BR /&gt;- name: category&lt;BR /&gt;expr: category&lt;BR /&gt;- name: order_date&lt;BR /&gt;expr: order_date&lt;BR /&gt;measures:&lt;BR /&gt;- name: Sales net&lt;BR /&gt;expr: SUM(sales_net_column)&lt;BR /&gt;- name: Sales net Total&lt;BR /&gt;expr: SUM(sales_net_column)&lt;BR /&gt;window:&lt;BR /&gt;- order: order_date&lt;BR /&gt;range: all&lt;BR /&gt;semiadditive: last&lt;/P&gt;
&lt;P&gt;Then you would query it:&lt;/P&gt;
&lt;P&gt;SELECT&lt;BR /&gt;category,&lt;BR /&gt;MEASURE(`Sales net`) as sales_net,&lt;BR /&gt;MEASURE(`Sales net Total`) as sales_net_total&lt;BR /&gt;FROM sales_metric_view&lt;BR /&gt;GROUP BY category&lt;BR /&gt;ORDER BY sales_net DESC&lt;/P&gt;
&lt;P&gt;This gives you the per-category sales net alongside the grand total, similar to what SUM(...) OVER() would produce.&lt;/P&gt;
&lt;P&gt;Note: Window measures are currently an experimental feature. See the documentation for full details on available range options (current, cumulative, trailing, leading, all).&lt;/P&gt;
&lt;P&gt;OPTION 2: USE THE WINDOW FUNCTION AT QUERY TIME INSTEAD&lt;/P&gt;
&lt;P&gt;As you already discovered, you can use window functions in the query that reads from the metric view, just not inside the metric view definition itself:&lt;/P&gt;
&lt;P&gt;SELECT&lt;BR /&gt;category,&lt;BR /&gt;MEASURE(`Sales net`) as sales_net,&lt;BR /&gt;SUM(MEASURE(`Sales net`)) OVER() AS sales_net_total&lt;BR /&gt;FROM sales_metric_view&lt;BR /&gt;GROUP BY category&lt;BR /&gt;ORDER BY sales_net DESC&lt;/P&gt;
&lt;P&gt;This approach works because the OVER() is applied at query time after the metric view engine has resolved the MEASURE() calls. This is a perfectly valid pattern and may be simpler if you only need this calculation in one specific query.&lt;/P&gt;
&lt;P&gt;DOCUMENTATION REFERENCES&lt;/P&gt;
&lt;P&gt;Metric views overview:&lt;BR /&gt;&lt;A href="https://docs.databricks.com/aws/en/metric-views/" target="_blank"&gt;https://docs.databricks.com/aws/en/metric-views/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Window measures in metric views:&lt;BR /&gt;&lt;A href="https://docs.databricks.com/aws/en/metric-views/data-modeling/window-measures" target="_blank"&gt;https://docs.databricks.com/aws/en/metric-views/data-modeling/window-measures&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Creating metric views:&lt;BR /&gt;&lt;A href="https://docs.databricks.com/aws/en/metric-views/create/" target="_blank"&gt;https://docs.databricks.com/aws/en/metric-views/create/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;In summary: the metric view definition language intentionally uses its own declarative window specification rather than SQL window function syntax. You can either define window measures in YAML using the window block, or apply standard SQL window functions at query time when reading from the metric view.&lt;/P&gt;
&lt;P&gt;* This reply used an agent system I built to research and draft this response based on the wide set of documentation I have available and previous memory. I personally review the draft for any obvious issues and for monitoring system reliability and update it when I detect any drift, but there is still a small chance that something is inaccurate, especially if you are experimenting with brand new features.&lt;/P&gt;</description>
    <pubDate>Sun, 08 Mar 2026 07:39:14 GMT</pubDate>
    <dc:creator>SteveOstrowski</dc:creator>
    <dc:date>2026-03-08T07:39:14Z</dc:date>
    <item>
      <title>Metric Views + Window Functions not supported</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/metric-views-window-functions-not-supported/m-p/149104#M2504</link>
      <description>&lt;P class=""&gt;&lt;SPAN class=""&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/25346"&gt;@Hubert-Dudek&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;I am getting following error:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;METRIC_VIEW_WINDOW_FUNCTION_NOT _SUPPORTED The metric &lt;/SPAN&gt;&lt;SPAN class=""&gt;view&lt;/SPAN&gt; &lt;SPAN class=""&gt;is&lt;/SPAN&gt; &lt;SPAN class=""&gt;not&lt;/SPAN&gt;&lt;SPAN class=""&gt; allowed &lt;/SPAN&gt;&lt;SPAN class=""&gt;to&lt;/SPAN&gt;&lt;SPAN class=""&gt; use &lt;/SPAN&gt;&lt;SPAN class=""&gt;window&lt;/SPAN&gt; &lt;SPAN class=""&gt;function (...)&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;With the following definition:&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;- name: Sales net Total&lt;BR /&gt;- expr: SUM(MEASURE(`Sales net`)) OVER())&lt;/P&gt;&lt;P class=""&gt;However following query works fine:&lt;/P&gt;&lt;P class=""&gt;```&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;SELECT&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;category&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;MEASURE(&lt;/SPAN&gt;&lt;SPAN&gt;`Sales net`&lt;/SPAN&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;SPAN&gt;as&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;sales_net,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;SUM&lt;/SPAN&gt;&lt;SPAN&gt;(MEASURE(&lt;/SPAN&gt;&lt;SPAN&gt;`Sales net`&lt;/SPAN&gt;&lt;SPAN&gt;)) &lt;/SPAN&gt;&lt;SPAN&gt;OVER&lt;/SPAN&gt;&lt;SPAN&gt;()&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;AS sales_net_total&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;FROM&lt;/SPAN&gt;&lt;SPAN&gt; sales_metric_view&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;GROUP BY&lt;/SPAN&gt; &lt;SPAN&gt;category&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;ORDER BY&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;sales_net &lt;/SPAN&gt;&lt;SPAN&gt;DESC&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;```&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Feb 2026 20:21:12 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/metric-views-window-functions-not-supported/m-p/149104#M2504</guid>
      <dc:creator>wrosa</dc:creator>
      <dc:date>2026-02-23T20:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: Metric Views + Window Functions not supported</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/metric-views-window-functions-not-supported/m-p/150199#M2523</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/217270"&gt;@wrosa&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;The error you are seeing (METRIC_VIEW_WINDOW_FUNCTION_NOT_SUPPORTED) is expected behavior. Metric views do not allow raw SQL window functions like SUM(...) OVER() directly in a measure's expr definition. This is by design because metric views use their own declarative window specification in the YAML definition rather than inline SQL window syntax.&lt;/P&gt;
&lt;P&gt;WHAT IS HAPPENING&lt;/P&gt;
&lt;P&gt;When you define a measure as:&lt;/P&gt;
&lt;P&gt;- name: Sales net Total&lt;BR /&gt;expr: SUM(MEASURE(`Sales net`)) OVER()&lt;/P&gt;
&lt;P&gt;The metric view engine rejects this because OVER() is standard SQL window function syntax, which is not permitted inside a measure expression. Measure expressions in metric views must be aggregate expressions (like SUM(), COUNT(), AVG(), etc.), optionally with FILTER clauses or arithmetic, but not SQL window functions.&lt;/P&gt;
&lt;P&gt;HOW TO ACHIEVE THE SAME RESULT&lt;/P&gt;
&lt;P&gt;You have two options depending on what you need.&lt;/P&gt;
&lt;P&gt;OPTION 1: USE THE METRIC VIEW WINDOW MEASURE YAML SYNTAX&lt;/P&gt;
&lt;P&gt;Metric views support "window measures" as a declarative feature. Instead of writing OVER() in the expr, you define a window block in the YAML. For example, if you want a grand total of Sales net across all rows, you would define it like this:&lt;/P&gt;
&lt;P&gt;measures:&lt;BR /&gt;- name: Sales net&lt;BR /&gt;expr: SUM(sales_net_column)&lt;BR /&gt;- name: Sales net Total&lt;BR /&gt;expr: SUM(sales_net_column)&lt;BR /&gt;window:&lt;BR /&gt;- order: &amp;lt;some_dimension&amp;gt;&lt;BR /&gt;range: all&lt;BR /&gt;semiadditive: last&lt;/P&gt;
&lt;P&gt;The "range: all" specification gives you the equivalent of OVER() (the entire dataset). The "order" field must reference one of your defined dimensions, and "semiadditive" controls how the value is summarized when that order dimension is not in the GROUP BY of your query.&lt;/P&gt;
&lt;P&gt;Here is a more concrete example. If you have a date dimension:&lt;/P&gt;
&lt;P&gt;dimensions:&lt;BR /&gt;- name: category&lt;BR /&gt;expr: category&lt;BR /&gt;- name: order_date&lt;BR /&gt;expr: order_date&lt;BR /&gt;measures:&lt;BR /&gt;- name: Sales net&lt;BR /&gt;expr: SUM(sales_net_column)&lt;BR /&gt;- name: Sales net Total&lt;BR /&gt;expr: SUM(sales_net_column)&lt;BR /&gt;window:&lt;BR /&gt;- order: order_date&lt;BR /&gt;range: all&lt;BR /&gt;semiadditive: last&lt;/P&gt;
&lt;P&gt;Then you would query it:&lt;/P&gt;
&lt;P&gt;SELECT&lt;BR /&gt;category,&lt;BR /&gt;MEASURE(`Sales net`) as sales_net,&lt;BR /&gt;MEASURE(`Sales net Total`) as sales_net_total&lt;BR /&gt;FROM sales_metric_view&lt;BR /&gt;GROUP BY category&lt;BR /&gt;ORDER BY sales_net DESC&lt;/P&gt;
&lt;P&gt;This gives you the per-category sales net alongside the grand total, similar to what SUM(...) OVER() would produce.&lt;/P&gt;
&lt;P&gt;Note: Window measures are currently an experimental feature. See the documentation for full details on available range options (current, cumulative, trailing, leading, all).&lt;/P&gt;
&lt;P&gt;OPTION 2: USE THE WINDOW FUNCTION AT QUERY TIME INSTEAD&lt;/P&gt;
&lt;P&gt;As you already discovered, you can use window functions in the query that reads from the metric view, just not inside the metric view definition itself:&lt;/P&gt;
&lt;P&gt;SELECT&lt;BR /&gt;category,&lt;BR /&gt;MEASURE(`Sales net`) as sales_net,&lt;BR /&gt;SUM(MEASURE(`Sales net`)) OVER() AS sales_net_total&lt;BR /&gt;FROM sales_metric_view&lt;BR /&gt;GROUP BY category&lt;BR /&gt;ORDER BY sales_net DESC&lt;/P&gt;
&lt;P&gt;This approach works because the OVER() is applied at query time after the metric view engine has resolved the MEASURE() calls. This is a perfectly valid pattern and may be simpler if you only need this calculation in one specific query.&lt;/P&gt;
&lt;P&gt;DOCUMENTATION REFERENCES&lt;/P&gt;
&lt;P&gt;Metric views overview:&lt;BR /&gt;&lt;A href="https://docs.databricks.com/aws/en/metric-views/" target="_blank"&gt;https://docs.databricks.com/aws/en/metric-views/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Window measures in metric views:&lt;BR /&gt;&lt;A href="https://docs.databricks.com/aws/en/metric-views/data-modeling/window-measures" target="_blank"&gt;https://docs.databricks.com/aws/en/metric-views/data-modeling/window-measures&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Creating metric views:&lt;BR /&gt;&lt;A href="https://docs.databricks.com/aws/en/metric-views/create/" target="_blank"&gt;https://docs.databricks.com/aws/en/metric-views/create/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;In summary: the metric view definition language intentionally uses its own declarative window specification rather than SQL window function syntax. You can either define window measures in YAML using the window block, or apply standard SQL window functions at query time when reading from the metric view.&lt;/P&gt;
&lt;P&gt;* This reply used an agent system I built to research and draft this response based on the wide set of documentation I have available and previous memory. I personally review the draft for any obvious issues and for monitoring system reliability and update it when I detect any drift, but there is still a small chance that something is inaccurate, especially if you are experimenting with brand new features.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Mar 2026 07:39:14 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/metric-views-window-functions-not-supported/m-p/150199#M2523</guid>
      <dc:creator>SteveOstrowski</dc:creator>
      <dc:date>2026-03-08T07:39:14Z</dc:date>
    </item>
  </channel>
</rss>

