<?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: Get last 2 years data from measure based on slicer in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-last-2-years-data-from-measure-based-on-slicer/m-p/3860378#M150797</link>
    <description>&lt;P&gt;Your slicer needs to be fed from a disconnected table. Then you use measures to sense its value and compute the expected outcome.&lt;/P&gt;</description>
    <pubDate>Mon, 22 Apr 2024 20:51:41 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2024-04-22T20:51:41Z</dc:date>
    <item>
      <title>Get last 2 years data from measure based on slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-last-2-years-data-from-measure-based-on-slicer/m-p/3859465#M150743</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;Need some help on the below dax statement.&lt;/P&gt;&lt;P&gt;Requirement:&lt;/P&gt;&lt;P&gt;Slicer = year (example 2023)&lt;BR /&gt;Table = Fact_Availability&lt;/P&gt;&lt;P&gt;Need count of equipmentno with filter as HireAvailability = "On Hire" for the last 2 years based on year from slicer.&lt;/P&gt;&lt;P&gt;Tried below but no luck.&lt;/P&gt;&lt;P&gt;Measure =&lt;BR /&gt;VAR StartDate = FIRSTDATE(Fact_Availability[CalendarDate])&lt;BR /&gt;VAR StartDateLY = DATEADD(StartDate,-2,YEAR)&lt;BR /&gt;VAR EndDate = LASTDATE(Fact_Availability[CalendarDate])&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE(&lt;BR /&gt;COUNT('Fact_Availability'[EquipmentNo]),&lt;BR /&gt;'Fact_Availability'[HireAvailability]="On Hire",&lt;BR /&gt;'Fact_Availability'[CalendarDate] &amp;gt;= StartDateLY &amp;amp;&amp;amp; 'Fact_Availability'[CalendarDate] &amp;lt;= EndDate&lt;BR /&gt;)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above measure returns only 2023 data because the year slicer has 2023 selected.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;When i check variable values individually it shows "StartDateLY" = 2021 and EndDate = 2023 which is correct.&lt;/P&gt;&lt;P&gt;but the above measure is rendering only 2023 data as the filter is 2023.&lt;/P&gt;&lt;P&gt;I need a dax statement which takes input from slicer as 2023 and gets the count of equipment numbers from 2021 till 2023.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 13:20:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-last-2-years-data-from-measure-based-on-slicer/m-p/3859465#M150743</guid>
      <dc:creator>haripbi</dc:creator>
      <dc:date>2024-04-22T13:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: Get last 2 years data from measure based on slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-last-2-years-data-from-measure-based-on-slicer/m-p/3860378#M150797</link>
      <description>&lt;P&gt;Your slicer needs to be fed from a disconnected table. Then you use measures to sense its value and compute the expected outcome.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 20:51:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-last-2-years-data-from-measure-based-on-slicer/m-p/3860378#M150797</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-04-22T20:51:41Z</dc:date>
    </item>
    <item>
      <title>Re: Get last 2 years data from measure based on slicer</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-last-2-years-data-from-measure-based-on-slicer/m-p/3861246#M150840</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="729644" data-lia-user-login="haripbi" class="lia-mention lia-mention-user"&gt;haripbi&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P style="margin: 0in; font-size: 11.0pt; color: black;"&gt;&lt;SPAN&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="100342" data-lia-user-login="lbendlin" class="lia-mention lia-mention-user"&gt;lbendlin&lt;/a&gt;&amp;nbsp;, thanks for your concern about this case. I tried to create a sample data myself based on the user's requirement and implemented the result. Please check if there is anything that can be improved. Here is my solution:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in; font-size: 11.0pt; color: black;"&gt;&lt;SPAN&gt;I create a table as you mentioned.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Then I create a new table. It is used as slicer.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Table = VALUES('Fact_Availability'[Year])&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Then I create a measure and you will get what you want.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;MEASURE =
VAR _Slicer =
    MAX ( 'Table'[Year] )
RETURN
    IF (
        YEAR ( MAX ( 'Fact_Availability'[CalendarDate] ) ) &amp;gt;= _Slicer - 2
            &amp;amp;&amp;amp; YEAR ( MAX ( 'Fact_Availability'[CalendarDate] ) ) &amp;lt;= _Slicer,
        1
    )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;img /&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 style="margin-bottom: 6.0pt;"&gt;&lt;SPAN&gt;Best Regards&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 6.0pt;"&gt;&lt;SPAN&gt;Yilong Zhou&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 6.0pt;"&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;helps&lt;/I&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2024 06:20:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Get-last-2-years-data-from-measure-based-on-slicer/m-p/3861246#M150840</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-04-23T06:20:16Z</dc:date>
    </item>
  </channel>
</rss>

