<?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: Customized Date Filtering in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customized-Date-Filtering/m-p/2419968#M64071</link>
    <description>&lt;P&gt;Thank you for providing a sample PBIX.&lt;/P&gt;
&lt;P&gt;You might be slightly overcomplicating things.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;CalenderMaster = CALENDAR("2017-01-01",MAX('data'[date]))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't use auto date/time, you already have your own calendar table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First you need a calculated table with all names&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Names = VALUES(data[name])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then a measure that computes the status for each name and the selected date.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;date status = 
var d = CALCULATE(max(data[date]),data[date]&amp;lt;=max(CalenderMaster[Date]),data[name]=SELECTEDVALUE(Names[name]))
return calculate(max(data[Status]),data[date]=d,data[name]=SELECTEDVALUE(Names[name]))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and that's it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: your calendar definition starts at 2017.&amp;nbsp; Your sample data events start MUCH earlier.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;see attached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next you need to figure out the status for each of your names at the point in time identified by the date slicer.&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;</description>
    <pubDate>Sun, 27 Mar 2022 21:35:47 GMT</pubDate>
    <dc:creator>lbendlin</dc:creator>
    <dc:date>2022-03-27T21:35:47Z</dc:date>
    <item>
      <title>Customized Date Filtering</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customized-Date-Filtering/m-p/2419407#M64032</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was wondering how I would create a measure to exclude the people who leave (have a status of -1) but include everyone with a status of 1 from before but not including the selected date.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I attached a sample power bi file.&lt;BR /&gt;&lt;A href="https://drive.google.com/file/d/1gyRlYRIZ0KckVOvFBFm6s2tGEq8MvpHM/view?usp=sharing" target="_blank" rel="nofollow noopener noreferrer"&gt;https://drive.google.com/file/d/1gyRlYRIZ0KckVOvFBFm6s2tGEq8MvpHM/view?usp=sharing&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 26 Mar 2022 22:32:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customized-Date-Filtering/m-p/2419407#M64032</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-26T22:32:55Z</dc:date>
    </item>
    <item>
      <title>Re: Customized Date Filtering</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customized-Date-Filtering/m-p/2419968#M64071</link>
      <description>&lt;P&gt;Thank you for providing a sample PBIX.&lt;/P&gt;
&lt;P&gt;You might be slightly overcomplicating things.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;CalenderMaster = CALENDAR("2017-01-01",MAX('data'[date]))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't use auto date/time, you already have your own calendar table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First you need a calculated table with all names&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Names = VALUES(data[name])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then a measure that computes the status for each name and the selected date.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;date status = 
var d = CALCULATE(max(data[date]),data[date]&amp;lt;=max(CalenderMaster[Date]),data[name]=SELECTEDVALUE(Names[name]))
return calculate(max(data[Status]),data[date]=d,data[name]=SELECTEDVALUE(Names[name]))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and that's it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: your calendar definition starts at 2017.&amp;nbsp; Your sample data events start MUCH earlier.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;see attached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next you need to figure out the status for each of your names at the point in time identified by the date slicer.&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;</description>
      <pubDate>Sun, 27 Mar 2022 21:35:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customized-Date-Filtering/m-p/2419968#M64071</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2022-03-27T21:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: Customized Date Filtering</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customized-Date-Filtering/m-p/2426468#M64461</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;According to your description, here's my solution.&lt;/P&gt;
&lt;P&gt;1.Create a Date table, put this new date column in the slicer.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Date = CALENDAR(DATE(2001,1,1),DATE(2020,1,1))&lt;/LI-CODE&gt;
&lt;P&gt;2.Create a measure.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Check =
IF (
    MAX ( 'data'[name] )
        IN SELECTCOLUMNS (
            FILTER ( ALL ( 'data' ), 'data'[Status] = -1 ),
            "Name", 'data'[name]
        )
            &amp;amp;&amp;amp; MAXX (
                FILTER (
                    ALL ( 'data' ),
                    'data'[Status] = -1
                        &amp;amp;&amp;amp; 'data'[name] = MAX ( 'data'[name] )
                ),
                'data'[date]
            )
                &amp;lt; MAXX ( ALLSELECTED ( 'Date'[Date] ), 'Date'[Date] )
            || MAXX (
                FILTER (
                    ALL ( 'data' ),
                    'data'[Status] = 1
                        &amp;amp;&amp;amp; 'data'[name] = MAX ( 'data'[name] )
                ),
                'data'[date]
            )
                &amp;gt; MAXX ( ALLSELECTED ( 'Date'[Date] ), 'Date'[Date] ),
    0,
    1
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;Put this measure in the visual filter and let the value is 1, get the correct result.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;I attach my sample below for reference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Community Support Team _ kalyj&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;helps,&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;then please consider&lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 10:15:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Customized-Date-Filtering/m-p/2426468#M64461</guid>
      <dc:creator>v-yanjiang-msft</dc:creator>
      <dc:date>2022-03-30T10:15:10Z</dc:date>
    </item>
  </channel>
</rss>

