<?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: Comparing values with the same date range in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-values-with-the-same-date-range/m-p/4156870#M165185</link>
    <description>&lt;P&gt;&lt;STRONG&gt;Step 1: Create a measure that captures the latest date selected in the slicer for the current year:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;MaxCurrentYearDate =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;MAX('Calendar'[Date]),&lt;BR /&gt;'Calendar'[Year] = MAX('Calendar'[Year])&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Step 2: Calculate Previous Years up to the Same Date&lt;/STRONG&gt;&lt;BR /&gt;Now create another measure to calculate the revenue for previous years but only up to the maximum date of the current year:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RevenueSamePeriod =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUM('Sales'[Revenue]),&lt;BR /&gt;FILTER(&lt;BR /&gt;ALL('Calendar'),&lt;BR /&gt;'Calendar'[Year] &amp;lt; MAX('Calendar'[Year]) &amp;amp;&amp;amp;&lt;BR /&gt;'Calendar'[MonthDay] &amp;lt;= DAY([MaxCurrentYearDate])&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;In this measure:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;ALL('Calendar') removes the date filter context so that it applies the logic across all years.&lt;/LI&gt;&lt;LI&gt;'Calendar'[Year] &amp;lt; MAX('Calendar'[Year]) ensures it only applies to previous years.&lt;/LI&gt;&lt;LI&gt;'Calendar'[MonthDay] &amp;lt;= DAY([MaxCurrentYearDate]) limits the comparison to the same number of days as in the current year.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Step 3: Apply this Measure in Your Bar Chart&lt;/STRONG&gt;&lt;BR /&gt;Use the new RevenueSamePeriod measure for the previous years, so the bar chart will only display values up to the same date range as in the current year.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;By using this approach, each year's data will be restricted to the same range of days as in the current year, ensuring a fair comparison across different years based on the slicer selection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Sep 2024 13:00:13 GMT</pubDate>
    <dc:creator>123abc</dc:creator>
    <dc:date>2024-09-18T13:00:13Z</dc:date>
    <item>
      <title>Comparing values with the same date range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-values-with-the-same-date-range/m-p/4156564#M165173</link>
      <description>&lt;P&gt;Hi Community&lt;BR /&gt;&lt;BR /&gt;I would like to get some help with a DAX measure. I want to have a bar chart like shown in the snippet, where i compare values from previous years, but my struggle is to have the same date range as my current year (in this case 2024/25) so in a month slicer i have selected september. this means that i have data from september 1st til september 17th. But my previous years shows the full month of september. How can i make sure it always follows the same range? how would a DAX measure look like to achieve this?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2024 10:42:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-values-with-the-same-date-range/m-p/4156564#M165173</guid>
      <dc:creator>Nicpet0</dc:creator>
      <dc:date>2024-09-18T10:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing values with the same date range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-values-with-the-same-date-range/m-p/4156870#M165185</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Step 1: Create a measure that captures the latest date selected in the slicer for the current year:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;MaxCurrentYearDate =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;MAX('Calendar'[Date]),&lt;BR /&gt;'Calendar'[Year] = MAX('Calendar'[Year])&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Step 2: Calculate Previous Years up to the Same Date&lt;/STRONG&gt;&lt;BR /&gt;Now create another measure to calculate the revenue for previous years but only up to the maximum date of the current year:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RevenueSamePeriod =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUM('Sales'[Revenue]),&lt;BR /&gt;FILTER(&lt;BR /&gt;ALL('Calendar'),&lt;BR /&gt;'Calendar'[Year] &amp;lt; MAX('Calendar'[Year]) &amp;amp;&amp;amp;&lt;BR /&gt;'Calendar'[MonthDay] &amp;lt;= DAY([MaxCurrentYearDate])&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;In this measure:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;ALL('Calendar') removes the date filter context so that it applies the logic across all years.&lt;/LI&gt;&lt;LI&gt;'Calendar'[Year] &amp;lt; MAX('Calendar'[Year]) ensures it only applies to previous years.&lt;/LI&gt;&lt;LI&gt;'Calendar'[MonthDay] &amp;lt;= DAY([MaxCurrentYearDate]) limits the comparison to the same number of days as in the current year.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Step 3: Apply this Measure in Your Bar Chart&lt;/STRONG&gt;&lt;BR /&gt;Use the new RevenueSamePeriod measure for the previous years, so the bar chart will only display values up to the same date range as in the current year.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;By using this approach, each year's data will be restricted to the same range of days as in the current year, ensuring a fair comparison across different years based on the slicer selection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2024 13:00:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-values-with-the-same-date-range/m-p/4156870#M165185</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2024-09-18T13:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing values with the same date range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-values-with-the-same-date-range/m-p/4161972#M165360</link>
      <description>&lt;P&gt;&lt;FONT&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="566246" data-lia-user-login="Nicpet0" class="lia-mention lia-mention-user"&gt;Nicpet0&lt;/a&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's my solution, hope it helps!&lt;/P&gt;
&lt;P&gt;1. Create a calculated column in the calendar table that marks whether each date falls within the same date range for the current year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;IsInCurrentYearRange = 
VAR CurrentYear = YEAR(MAX('Table'[Date]))
VAR CurrentMonth = MONTH(MAX('Table'[Date]))
VAR MaxCurrentDate = DAY(MAX('Table'[Date]))
RETURN 
IF(
    'Calendar'[Year] &amp;lt; CurrentYear &amp;amp;&amp;amp;
    'Calendar'[Month] == CurrentMonth &amp;amp;&amp;amp;
    'Calendar'[Day] &amp;gt; MaxCurrentDate,
    0,
    1
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Create a measure to calculate revenue in the same date range.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SameDateRangeRevenue = 
CALCULATE(
    SUM('Table'[Value]),
    FILTER(
        'Calendar',
        'Calendar'[IsInCurrentYearRange] = 1
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Here is final result.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Jarvis Tang&lt;BR /&gt;If this post &lt;EM&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;/EM&gt;, then please consider &lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt; to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2024 09:38:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-values-with-the-same-date-range/m-p/4161972#M165360</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-09-20T09:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing values with the same date range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-values-with-the-same-date-range/m-p/4417404#M175410</link>
      <description>&lt;P&gt;excellent&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 09:17:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Comparing-values-with-the-same-date-range/m-p/4417404#M175410</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2025-02-19T09:17:31Z</dc:date>
    </item>
  </channel>
</rss>

