<?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: Difference between DATESYTD() and DATESBETWEEN() in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Difference-between-DATESYTD-and-DATESBETWEEN/m-p/4841458#M184840</link>
    <description>&lt;P&gt;What is the code for the version where you are using DATESBETWEEN ?&lt;/P&gt;</description>
    <pubDate>Fri, 03 Oct 2025 10:53:33 GMT</pubDate>
    <dc:creator>johnt75</dc:creator>
    <dc:date>2025-10-03T10:53:33Z</dc:date>
    <item>
      <title>Difference between DATESYTD() and DATESBETWEEN()</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Difference-between-DATESYTD-and-DATESBETWEEN/m-p/4841300#M184831</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to figure out how PBI handles these commands differently. I can get a simple monthly cumulative sum of distinct counts by using:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;CALCULATE&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;DISTINCTCOUNTNOBLANK&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Key]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;DATESYTD&lt;/SPAN&gt;&lt;SPAN&gt;(Calendar&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;))&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and adding this to a visual with months (from the Calendar table) on another axis.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I change the DATESYTD to DATESBETWEEN I only get the yearly total for each month. If I run DATESYTD() and DATESBETWEEN() in Dax studio, I get the same table, so what changes here?&lt;/P&gt;</description>
      <pubDate>Fri, 03 Oct 2025 08:46:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Difference-between-DATESYTD-and-DATESBETWEEN/m-p/4841300#M184831</guid>
      <dc:creator>Petja</dc:creator>
      <dc:date>2025-10-03T08:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between DATESYTD() and DATESBETWEEN()</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Difference-between-DATESYTD-and-DATESBETWEEN/m-p/4841458#M184840</link>
      <description>&lt;P&gt;What is the code for the version where you are using DATESBETWEEN ?&lt;/P&gt;</description>
      <pubDate>Fri, 03 Oct 2025 10:53:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Difference-between-DATESYTD-and-DATESBETWEEN/m-p/4841458#M184840</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2025-10-03T10:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between DATESYTD() and DATESBETWEEN()</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Difference-between-DATESYTD-and-DATESBETWEEN/m-p/4841683#M184844</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="389466" data-lia-user-login="Petja" class="lia-mention lia-mention-user"&gt;Petja&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Thank you for your question on the Microsoft Fabric Community Forum.&lt;/P&gt;
&lt;P&gt;To clarify the difference between DATESYTD() and DATESBETWEEN() in Power BI:&lt;/P&gt;
&lt;P&gt;Difference - DATESYTD(&amp;lt;dates&amp;gt;) : Returns a dynamic set of dates from the start of the year up to the last date in the current filter context, automatically adjusting based on your visual (e.g., month on the axis).&lt;/P&gt;
&lt;P&gt;DATESBETWEEN(&amp;lt;dates&amp;gt;, &amp;lt;start_date&amp;gt;, &amp;lt;end_date&amp;gt;)&amp;nbsp;: Returns a static set of dates between specified start and end dates and does not adjust automatically unless you make it dynamic.&lt;/P&gt;
&lt;P&gt;Different Results,&amp;nbsp;&lt;SPAN&gt;Using DATESYTD(Calendar[Date]) with months on the x-axis provides a cumulative total by month (e.g., January = Jan, February = Jan + Feb, etc.).&lt;/SPAN&gt;Using DATESBETWEEN(Calendar[Date], DATE(2025,1,1), DATE(2025,12,31)) returns the same yearly total for each month, as the range is fixed.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Making DATESBETWEEN() Dynamic:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;You can make DATESBETWEEN() cumulative by using:&lt;BR /&gt;CALCULATE(&lt;BR /&gt;DISTINCTCOUNTNOBLANK('Table'[Key]),&lt;BR /&gt;DATESBETWEEN(&lt;BR /&gt;Calendar[Date],&lt;BR /&gt;DATE(YEAR(MIN(Calendar[Date])), 1, 1), -- Start of the year&lt;BR /&gt;MAX(Calendar[Date]) -- Current context end date&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;MIN(Calendar[Date]) and MAX(Calendar[Date]) ensure the date range adjusts dynamically for each row in your visual, matching DATESYTD()’s cumulative behavior.&lt;/P&gt;
&lt;P&gt;Recommendation: &lt;BR /&gt;Use DATESYTD() for YTD calculations unless you require a custom date range.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;References:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;A title="https://learn.microsoft.com/en-us/dax/datesytd-function-dax" href="https://learn.microsoft.com/en-us/dax/datesytd-function-dax" target="_blank" rel="noreferrer noopener"&gt;DATESYTD function – Microsoft Docs&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A title="https://learn.microsoft.com/en-us/dax/datesbetween-function-dax" href="https://learn.microsoft.com/en-us/dax/datesbetween-function-dax" target="_blank" rel="noreferrer noopener"&gt;DATESBETWEEN function – Microsoft Docs&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Oct 2025 10:22:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Difference-between-DATESYTD-and-DATESBETWEEN/m-p/4841683#M184844</guid>
      <dc:creator>v-sshirivolu</dc:creator>
      <dc:date>2025-10-08T10:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between DATESYTD() and DATESBETWEEN()</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Difference-between-DATESYTD-and-DATESBETWEEN/m-p/4843171#M184876</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="389466" data-lia-user-login="Petja" class="lia-mention lia-mention-user"&gt;Petja&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;I hope the information provided above assists you in resolving the issue. If you have any additional questions or concerns, please do not hesitate to contact us. We are here to support you and will be happy to help with any further assistance you may need.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2025 10:32:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Difference-between-DATESYTD-and-DATESBETWEEN/m-p/4843171#M184876</guid>
      <dc:creator>v-sshirivolu</dc:creator>
      <dc:date>2025-10-06T10:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between DATESYTD() and DATESBETWEEN()</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Difference-between-DATESYTD-and-DATESBETWEEN/m-p/4843196#M184878</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your response. Based on my experimenting, the measure becomes undynamic if you try to adjust BOTH, the start and the end date.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The problem I'm trying to solve here is that the data I have is lagged by days, so during the first days of a new year, I'd need the measures to show last years (and the year before that) data for some days.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Oct 2025 10:50:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Difference-between-DATESYTD-and-DATESBETWEEN/m-p/4843196#M184878</guid>
      <dc:creator>Petja</dc:creator>
      <dc:date>2025-10-06T10:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between DATESYTD() and DATESBETWEEN()</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Difference-between-DATESYTD-and-DATESBETWEEN/m-p/4845336#M184929</link>
      <description>&lt;P&gt;Thank you for clarifying,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="389466" data-lia-user-login="Petja" class="lia-mention lia-mention-user"&gt;Petja&lt;/a&gt;&amp;nbsp;. &lt;BR /&gt;DATESBETWEEN() loses its dynamic nature when both its start and end dates are set outside the current filter context, such as when using ALL() or REMOVEFILTERS() on the Calendar before MIN/MAX. This causes the same full-year range to be applied to every row, so each month shows the same annual total. To keep things dynamic and handle a few days of new-year data lag, you can either calculate an effective end date for each row and build YTD based on that year, or continue with DATESYTD() and shift the context back by the lag. Both options let the range adjust per row and maintain last year’s running total during the first days of the new year.&lt;/P&gt;
&lt;P&gt;For more control, you can use this effective end YTD approach:&lt;/P&gt;
&lt;P&gt;[Distinct Keys] =&lt;BR /&gt;DISTINCTCOUNTNOBLANK('Fact'[Key])&lt;/P&gt;
&lt;P&gt;[YTD (Lag-Aware, Explicit End)] =&lt;BR /&gt;VAR LagDays&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 5&amp;nbsp; &amp;nbsp;- adjust as needed&lt;BR /&gt;VAR ContextEnd&amp;nbsp;&amp;nbsp; = MAX('Calendar'[Date])&lt;BR /&gt;VAR LastFactDate = CALCULATE(MAX('Fact'[Date]), ALL('Fact'))&lt;BR /&gt;VAR EffectiveEnd = MIN(ContextEnd, LastFactDate) - LagDays&lt;BR /&gt;VAR EffectiveStart = DATE(YEAR(EffectiveEnd), 1, 1)&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE(&lt;BR /&gt;&amp;nbsp;&amp;nbsp; [Distinct Keys],&lt;BR /&gt;&amp;nbsp;&amp;nbsp; DATESBETWEEN('Calendar'[Date], EffectiveStart, EffectiveEnd)&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;This measure stays dynamic since ContextEnd uses the current row context. At the start of January, if there’s a data lag, EffectiveEnd stays in the previous year, so the measure continues last year’s YTD until the lag is over.&lt;/P&gt;
&lt;P&gt;If your Date table is continuous and set up as a Date table, you can also use a concise method by shifting the context with the lag and still using DATESYTD():&lt;/P&gt;
&lt;P&gt;[YTD (Lag-Aware, DATEADD Shift)] =&lt;BR /&gt;VAR LagDays = 5&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE(&lt;BR /&gt;&amp;nbsp;&amp;nbsp; [Distinct Keys],&lt;BR /&gt;&amp;nbsp;&amp;nbsp; DATESYTD('Calendar'[Date]),&lt;BR /&gt;&amp;nbsp;&amp;nbsp; DATEADD('Calendar'[Date], -LagDays, DAY)&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;This approach returns the year-to-date value as of the current date minus LagDays, so for the first few days of the year, last year’s totals will be shown.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Oct 2025 09:43:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Difference-between-DATESYTD-and-DATESBETWEEN/m-p/4845336#M184929</guid>
      <dc:creator>v-sshirivolu</dc:creator>
      <dc:date>2025-10-08T09:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between DATESYTD() and DATESBETWEEN()</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Difference-between-DATESYTD-and-DATESBETWEEN/m-p/4846268#M184955</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the first method you described seems to somewhat work, although using:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;LagDays = 365&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;gives slightly different results for some months than using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Calculate&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;DISTINCTCOUNTNOBLANK&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Fact'&lt;/SPAN&gt;&lt;SPAN&gt;[Key]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;SAMEPERIODLASTYEAR&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;DATESYTD&lt;/SPAN&gt;&lt;SPAN&gt;(Calendar&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;)))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;EDIT: figured out why some of the newest months had differing numbers (the newest date in data used was before October), still have the problem that January has differing numbers.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Using the latter method you described does not work similarly to DATESYTD as it gives the sum per month and not yearly cumulative per month as DATESYTD.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Oct 2025 07:18:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Difference-between-DATESYTD-and-DATESBETWEEN/m-p/4846268#M184955</guid>
      <dc:creator>Petja</dc:creator>
      <dc:date>2025-10-09T07:18:21Z</dc:date>
    </item>
  </channel>
</rss>

