<?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 DATESINPERIOD values don't match on most recent Year period in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATESINPERIOD-values-don-t-match-on-most-recent-Year-period/m-p/4123237#M163723</link>
    <description>&lt;P&gt;I have implemented the following DATESINPERIOD pattern:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt; Design Area Avg Previous Period (converted) =    
    SWITCH(
        TRUE(),
        ISINSCOPE( 'Date'[Date] ),
            CALCULATE( [Design Area Avg (sum)] , DATEADD( 'Date'[Date], -1, DAY )),
        ISINSCOPE( 'Date'[Fiscal Month] ),
            CALCULATE( [Design Area Avg (sum)], DATEADD( 'Date'[Date], -1, MONTH )),
        ISINSCOPE( 'Date'[Fiscal Quarter] ),
            CALCULATE( [Design Area Avg (sum)] , DATEADD( 'Date'[Date], -1, QUARTER )),
        ISINSCOPE( 'Date'[Fiscal Year] ),
            CALCULATE( [Design Area Avg (sum)] , DATEADD( 'Date'[Date], -1, YEAR ))
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Except that in the most recent Year period we can see that the correct value for the previous year is not reported. This is consistent for two different measures, following the same pattern.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;My hypothesis (that I'm looking for confirmation of) is that the previous period result for the current year matches the 'exact' period. That is in the context of FY24 for FY23 it is calculating from August 28th, it is not calculating for the entire period of '23.&lt;BR /&gt;&lt;BR /&gt;Is that correct or is there something else going on that I'm either forgotten about or don't know?&lt;/P&gt;</description>
    <pubDate>Wed, 28 Aug 2024 16:43:32 GMT</pubDate>
    <dc:creator>rpiboy_1</dc:creator>
    <dc:date>2024-08-28T16:43:32Z</dc:date>
    <item>
      <title>DATESINPERIOD values don't match on most recent Year period</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATESINPERIOD-values-don-t-match-on-most-recent-Year-period/m-p/4123237#M163723</link>
      <description>&lt;P&gt;I have implemented the following DATESINPERIOD pattern:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt; Design Area Avg Previous Period (converted) =    
    SWITCH(
        TRUE(),
        ISINSCOPE( 'Date'[Date] ),
            CALCULATE( [Design Area Avg (sum)] , DATEADD( 'Date'[Date], -1, DAY )),
        ISINSCOPE( 'Date'[Fiscal Month] ),
            CALCULATE( [Design Area Avg (sum)], DATEADD( 'Date'[Date], -1, MONTH )),
        ISINSCOPE( 'Date'[Fiscal Quarter] ),
            CALCULATE( [Design Area Avg (sum)] , DATEADD( 'Date'[Date], -1, QUARTER )),
        ISINSCOPE( 'Date'[Fiscal Year] ),
            CALCULATE( [Design Area Avg (sum)] , DATEADD( 'Date'[Date], -1, YEAR ))
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Except that in the most recent Year period we can see that the correct value for the previous year is not reported. This is consistent for two different measures, following the same pattern.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;My hypothesis (that I'm looking for confirmation of) is that the previous period result for the current year matches the 'exact' period. That is in the context of FY24 for FY23 it is calculating from August 28th, it is not calculating for the entire period of '23.&lt;BR /&gt;&lt;BR /&gt;Is that correct or is there something else going on that I'm either forgotten about or don't know?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2024 16:43:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATESINPERIOD-values-don-t-match-on-most-recent-Year-period/m-p/4123237#M163723</guid>
      <dc:creator>rpiboy_1</dc:creator>
      <dc:date>2024-08-28T16:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: DATESINPERIOD values don't match on most recent Year period</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATESINPERIOD-values-don-t-match-on-most-recent-Year-period/m-p/4123972#M163757</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="452756" data-lia-user-login="rpiboy_1" class="lia-mention lia-mention-user"&gt;rpiboy_1&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, your hypothesis is correct, if I have understood you correctly &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;To describe it in more detail:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Time intelligence functions are computed in the context of dates that actually exist in the 'Date' table (that are visible in the filter context where the function is called).&lt;/LI&gt;
&lt;LI&gt;So if a partial month/quarter/year is present in the 'Date' table, then any time intelligence functions will operate on those partial periods.&lt;/LI&gt;
&lt;LI&gt;For example, if we assume that FY is equivalent to calendar year (not sure if that's correct in your case) and the 'Date' table ends at 2024-08-28, then a filter of&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;'Date'[Fiscal Year] = "FY 2024"&lt;/FONT&gt;&lt;BR /&gt;&lt;/STRONG&gt;is equivalent to&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;DATESBETWEEN ( 'Date'[Date], dt"2024-01-01", dt"2024-08-28" )&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;Therefore in the context of the filter&amp;nbsp;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;'Date'[Fiscal Year] = "FY 2024"&lt;BR /&gt;DATEADD ( 'Date'[Date], -1, YEAR )&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;evaluates to&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;DATESBETWEEN ( 'Date'[Date], dt"2023-01-01", dt"2023-08-28" )&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Because of this behaviour, your 'Date' table should generally include complete years (however years are defined) spanning your required date range.&lt;/P&gt;
&lt;P data-unlink="true"&gt;&lt;A href="https://dax.guide/functions/time-intelligence/#:~:text=All%20dates%20need%20to%20be%20present%20for%20the%20years%20required." target="_blank" rel="noopener"&gt;https://dax.guide/functions/time-intelligence/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If some time intelligence need to be based on partial periods, then there are some examples of handling this here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.daxpatterns.com/standard-time-related-calculations/" target="_blank" rel="noopener"&gt;https://www.daxpatterns.com/standard-time-related-calculations/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2024 03:15:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATESINPERIOD-values-don-t-match-on-most-recent-Year-period/m-p/4123972#M163757</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2024-08-29T03:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: DATESINPERIOD values don't match on most recent Year period</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATESINPERIOD-values-don-t-match-on-most-recent-Year-period/m-p/4125408#M163818</link>
      <description>&lt;P&gt;Thanks for confirming. I also did confirm when I manipulated the Date Slicer on the report (duh!). This ultimatly leads to another question which at the moment remains un-resolved. Is it worth going about adding to the measure to automatically calculated the correct overall period, regardless of the presence of a slicer?&lt;BR /&gt;&lt;BR /&gt;In my case I have a date between slicer so the end users can 'narrow' their focus. This of course is what through the DATESINPERIOD measure off. Therefore, should I consider calculating the full year, quarter and month span of the 'latest' of each so that the previous period is complete?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is really more of a UX question, though I'm also a bit uncertain the best technical approach.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I took a look at 'end of year' and 'end of month' etc. in dax.guide, and I wasn't entirely certain of the best way to go about getting the right data to pass to the DATEADD function. I'm confident the technical aspect could be resolved, but this leaves oustanding the question of 'should it be', or should I simply ensure Report consumers are educated as to what to expect when they do manipulate the Date Slicer?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2024 16:53:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATESINPERIOD-values-don-t-match-on-most-recent-Year-period/m-p/4125408#M163818</guid>
      <dc:creator>rpiboy_1</dc:creator>
      <dc:date>2024-08-29T16:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: DATESINPERIOD values don't match on most recent Year period</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATESINPERIOD-values-don-t-match-on-most-recent-Year-period/m-p/4134276#M164217</link>
      <description>&lt;P&gt;Just realised I didn't get back to you on this one &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;As far as the UX question, some sort of conditional formatting (e.g. background colour) might be a good way of flagging partial periods. This would require a measure with logic to detect partial periods.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To convert partial to full periods, take a look at &lt;A href="https://dax.guide/parallelperiod/" target="_blank" rel="noopener"&gt;PARALLELPERIOD&lt;/A&gt;&amp;nbsp;which would be my go-to function. It expands a given date range to complete months/quarters/years and shifts if needed. You may want to combine it with DATEADD or other functions.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2024 00:44:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DATESINPERIOD-values-don-t-match-on-most-recent-Year-period/m-p/4134276#M164217</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2024-09-05T00:44:14Z</dc:date>
    </item>
  </channel>
</rss>

