<?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 Period to Date not working in Warehousing &amp; Analytics</title>
    <link>https://community.databricks.com/t5/warehousing-analytics/metric-views-window-period-to-date-not-working/m-p/153586#M2549</link>
    <description>&lt;P&gt;Hi Ashwin. Thanks for looking into this. Your description of the behaviour and the options matches my understanding, but from my perspective this is a defect: I don't think there's a reasonable interpretation of "period to date" (which is the documented capability) as actually meaning "a full period from beginning to end where the period is the last one for which there is data".&lt;/P&gt;&lt;P&gt;Regarding the CURRENT_DATE() workaround, metrics materialized views can be refreshed as frequently as every hour. I understand that materialization doesn't make sense when there is a genuine dependency on a value that is unknown when the materialized data is calculated, but that is not the case in this example, as we are using "current" time at a granularity three orders of magnitude more coarse than this.&lt;/P&gt;&lt;P&gt;I will use the workaround for now, but is there a process for getting this raised with product / engineering?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jamie&lt;/P&gt;</description>
    <pubDate>Tue, 07 Apr 2026 05:58:34 GMT</pubDate>
    <dc:creator>jroots</dc:creator>
    <dc:date>2026-04-07T05:58:34Z</dc:date>
    <item>
      <title>Metric Views Window Period to Date not working</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/metric-views-window-period-to-date-not-working/m-p/153551#M2547</link>
      <description>&lt;P&gt;The &lt;A href="https://docs.databricks.com/aws/en/metric-views/data-modeling/window-measures" target="_self"&gt;documentation&lt;/A&gt; gives an example of a period to date measure. The intention is to give the sum (in this example) of orders in the &lt;EM&gt;current&amp;nbsp;&lt;/EM&gt;year to date. However, what actually happens is that the measure returns the result for the most recent period for which there are entries. If the current year has no rows, it returns the result for the most recent year which does. (There is a workaround, which is to use a filter with current_timestamp(), but then materialized views don't work.)&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;See results and measure definition attached. The measure definition is taken directly from the referenced documentation.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2026 16:47:20 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/metric-views-window-period-to-date-not-working/m-p/153551#M2547</guid>
      <dc:creator>jroots</dc:creator>
      <dc:date>2026-04-06T16:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: Metric Views Window Period to Date not working</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/metric-views-window-period-to-date-not-working/m-p/153559#M2548</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/225121"&gt;@jroots&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;On some research, I can see that the YAML in the docs is doing what window measures are defined to do, but the wording is perhaps a bit misleading. In the below example you shared,&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Screenshot 2026-04-06 at 18.41.15.png" style="width: 352px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/25718iCF7693DE055D4731/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2026-04-06 at 18.41.15.png" alt="Screenshot 2026-04-06 at 18.41.15.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#993366"&gt;range: current&lt;/FONT&gt; means "rows whose order value equals the current row’s value,"...&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;FONT color="#993366"&gt;and semiadditive:&lt;/FONT&gt; last says "when that order dimension (here year and date) isn’t grouped, use the last value in that window.” &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;When you query MEASURE(ytd_sales) without grouping by year or date, the engine selects the last date from the last year in the data and returns that year-to-date total. If no data for the actual calendar year contains current_date(), it naturally falls back to the most recent year that does have rows.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;To get "YTD for the calendar year containing current_date()," you currently have to push the notion of "current year" into the query instead of the metric view definition, for example, by filtering on DATE_TRUNC('year', date) = DATE_TRUNC('year', CURRENT_DATE()). Putting CURRENT_DATE() / CURRENT_TIMESTAMP() directly in the metric view YAML makes the definition invoker-dependent, which is why materialized metric views then stop working (they can’t be reused if the definition depends on evaluation time).&lt;/P&gt;
&lt;P&gt;Does this give you a direction?&lt;/P&gt;
&lt;P class="p1"&gt;&lt;FONT size="2" color="#FF6600"&gt;&lt;STRONG&gt;&lt;I&gt;If this answer resolves your question, could you mark it as “Accept as Solution”? That helps other users quickly find the correct fix.&lt;/I&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;I&gt;&lt;/I&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2026 19:22:32 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/metric-views-window-period-to-date-not-working/m-p/153559#M2548</guid>
      <dc:creator>Ashwin_DSA</dc:creator>
      <dc:date>2026-04-06T19:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: Metric Views Window Period to Date not working</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/metric-views-window-period-to-date-not-working/m-p/153586#M2549</link>
      <description>&lt;P&gt;Hi Ashwin. Thanks for looking into this. Your description of the behaviour and the options matches my understanding, but from my perspective this is a defect: I don't think there's a reasonable interpretation of "period to date" (which is the documented capability) as actually meaning "a full period from beginning to end where the period is the last one for which there is data".&lt;/P&gt;&lt;P&gt;Regarding the CURRENT_DATE() workaround, metrics materialized views can be refreshed as frequently as every hour. I understand that materialization doesn't make sense when there is a genuine dependency on a value that is unknown when the materialized data is calculated, but that is not the case in this example, as we are using "current" time at a granularity three orders of magnitude more coarse than this.&lt;/P&gt;&lt;P&gt;I will use the workaround for now, but is there a process for getting this raised with product / engineering?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jamie&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2026 05:58:34 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/metric-views-window-period-to-date-not-working/m-p/153586#M2549</guid>
      <dc:creator>jroots</dc:creator>
      <dc:date>2026-04-07T05:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: Metric Views Window Period to Date not working</title>
      <link>https://community.databricks.com/t5/warehousing-analytics/metric-views-window-period-to-date-not-working/m-p/153605#M2550</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/225121"&gt;@jroots&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Thank you for your feedback. I have flagged this issue internally for clarification and will let you know as soon as I receive more information.&lt;/P&gt;
&lt;P&gt;In the meantime, feel free to provide feedback on the documentation page. You should see an option on the right side of the window to do so.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Feedback.png" style="width: 744px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/25733i6F6E47E527197D64/image-size/large?v=v2&amp;amp;px=999" role="button" title="Feedback.png" alt="Feedback.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please keep in mind that this is an experimental feature.&lt;/P&gt;
&lt;P class="p1"&gt;&lt;FONT size="2" color="#FF6600"&gt;&lt;STRONG&gt;&lt;I&gt;If this answer resolves your question, could you mark it as “Accept as Solution”? That helps other users quickly find the correct fix.&lt;/I&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;I&gt;&lt;/I&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2026 09:02:25 GMT</pubDate>
      <guid>https://community.databricks.com/t5/warehousing-analytics/metric-views-window-period-to-date-not-working/m-p/153605#M2550</guid>
      <dc:creator>Ashwin_DSA</dc:creator>
      <dc:date>2026-04-07T09:02:25Z</dc:date>
    </item>
  </channel>
</rss>

