<?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: Measure to filter table based on 2 date fields (purchase, disposal) in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-filter-table-based-on-2-date-fields-purchase-disposal/m-p/2624127#M76576</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="408748" data-lia-user-login="REWINDER" class="lia-mention lia-mention-user"&gt;REWINDER&lt;/a&gt; , change as per need&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;active vehicles userelationship = CALCULATE ( CALCULATE ( COUNTROWS ( FleetActivity )Userelationship(FleetActivity[ReplacementDate],dimDate2[Date_pk]) )&lt;BR /&gt;, FILTER ( ALL ( FleetActivity ), FleetActivity[ReplacementDate] &amp;lt;= MAX ( dimDate2[Date_pk] ) &amp;amp;&amp;amp; FleetActivity[ReplacementDate] &amp;gt;= MIN ( dimDate2[Date_pk] ) ))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need the filter you have used only when you want filter purchase date not the replacement date&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this should do&lt;/P&gt;
&lt;P&gt;CALCULATE ( COUNTROWS ( FleetActivity )Userelationship(FleetActivity[ReplacementDate],dimDate2[Date_pk]) )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;example&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://radacad.com/userelationship-or-role-playing-dimension-dealing-with-inactive-relationships-in-power-bi" target="_blank"&gt;https://radacad.com/userelationship-or-role-playing-dimension-dealing-with-inactive-relationships-in-power-bi&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Jul 2022 07:11:12 GMT</pubDate>
    <dc:creator>amitchandak</dc:creator>
    <dc:date>2022-07-07T07:11:12Z</dc:date>
    <item>
      <title>Measure to filter table based on 2 date fields (purchase, disposal)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-filter-table-based-on-2-date-fields-purchase-disposal/m-p/2623902#M76563</link>
      <description>&lt;P&gt;Hi everyone,&lt;BR /&gt;&lt;BR /&gt;Though I thought my problem was solved earlier this week:&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/DAX-Commands-and-Tips/Measure-to-filter-rows-based-on-two-dates-begin-and-end-date/td-p/2618360#M76186" target="_blank" rel="noopener"&gt;https://community.powerbi.com/t5/DAX-Commands-and-Tips/Measure-to-filter-rows-based-on-two-dates-begin-and-end-date/td-p/2618360#M76186&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It unfortunately was not. (cannot seem to UNsolve that topic)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to get a measure with Active vehicles number, ClassStructure, By year (&amp;gt;= [PurchaseDate], &amp;lt;=[ReplacementDate], .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Presented but NOT correctly working option was:&amp;nbsp;&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------------&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;P&gt;#Vehicles Active =CALCULATE (&lt;BR /&gt;COUNTROWS ( FleetActivity ),&lt;BR /&gt;FILTER (ALL ( FleetActivity ),&lt;BR /&gt;FleetActivity[PurchaseDate] &amp;lt;= MAX ( dimDate2[Date_pk] )&lt;BR /&gt;&amp;amp;&amp;amp; FleetActivity[ReplacementDate] &amp;gt;= MIN ( dimDate2[Date_pk] )&lt;BR /&gt;))&lt;BR /&gt;-------------------------------------------------------------------------------------&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;EM&gt;&amp;gt;&amp;gt; My thinking is that the problem lies with the relationship to the Date table ( 1. with [PurchaseDate] and 2. with [ReplacementDate]), So I tried Userelationship: but it gives me the error that it can only be used in a Calculate syntax.&amp;nbsp;&lt;/EM&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;-----------------------------------------------------------------------------------&lt;/EM&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;active vehicles userelationship = CALCULATE ( COUNTROWS ( FleetActivity ), FILTER ( ALL ( FleetActivity ), FleetActivity[PurchaseDate] &amp;lt;= MAX ( dimDate2[Date_pk] ) &amp;amp;&amp;amp; Userelationship(FleetActivity[ReplacementDate],dimDate2[Date_pk]) &amp;gt;= MIN ( dimDate2[Date_pk] ) ))&amp;nbsp;&lt;BR /&gt;------------------------------------------------------------------------------------&lt;/EM&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/DAX-Commands-and-Tips/Measure-to-filter-rows-based-on-two-dates-begin-and-end-date/td-p/2618360#M76186" target="_blank" rel="noopener"&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN&gt;&lt;STRONG&gt;Date table and relationships:&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/EM&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/DAX-Commands-and-Tips/Measure-to-filter-rows-based-on-two-dates-begin-and-end-date/td-p/2618360#M76186" target="_blank" rel="noopener"&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/DAX-Commands-and-Tips/Measure-to-filter-rows-based-on-two-dates-begin-and-end-date/td-p/2618360#M76186" target="_blank" rel="noopener"&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;img /&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/A&gt;&lt;/P&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;I wanted to share a Pbix test file, but unfortunately it is not supported.&amp;nbsp;&lt;BR /&gt;Also, Sorry I had to re-open this question: if anyone knows how to (UN)solve the other topic, happy to do that.&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;BR /&gt;Thank you in advance!&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 07 Jul 2022 05:29:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-filter-table-based-on-2-date-fields-purchase-disposal/m-p/2623902#M76563</guid>
      <dc:creator>REWINDER</dc:creator>
      <dc:date>2022-07-07T05:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Measure to filter table based on 2 date fields (purchase, disposal)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-filter-table-based-on-2-date-fields-purchase-disposal/m-p/2624127#M76576</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="408748" data-lia-user-login="REWINDER" class="lia-mention lia-mention-user"&gt;REWINDER&lt;/a&gt; , change as per need&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;active vehicles userelationship = CALCULATE ( CALCULATE ( COUNTROWS ( FleetActivity )Userelationship(FleetActivity[ReplacementDate],dimDate2[Date_pk]) )&lt;BR /&gt;, FILTER ( ALL ( FleetActivity ), FleetActivity[ReplacementDate] &amp;lt;= MAX ( dimDate2[Date_pk] ) &amp;amp;&amp;amp; FleetActivity[ReplacementDate] &amp;gt;= MIN ( dimDate2[Date_pk] ) ))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need the filter you have used only when you want filter purchase date not the replacement date&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this should do&lt;/P&gt;
&lt;P&gt;CALCULATE ( COUNTROWS ( FleetActivity )Userelationship(FleetActivity[ReplacementDate],dimDate2[Date_pk]) )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;example&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://radacad.com/userelationship-or-role-playing-dimension-dealing-with-inactive-relationships-in-power-bi" target="_blank"&gt;https://radacad.com/userelationship-or-role-playing-dimension-dealing-with-inactive-relationships-in-power-bi&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 07:11:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-filter-table-based-on-2-date-fields-purchase-disposal/m-p/2624127#M76576</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-07-07T07:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: Measure to filter table based on 2 date fields (purchase, disposal)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-filter-table-based-on-2-date-fields-purchase-disposal/m-p/2624413#M76590</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;&amp;nbsp;, Thank you.&lt;BR /&gt;&lt;BR /&gt;Though it gets the right values at the end of the date range,&lt;/P&gt;&lt;P&gt;at the beginning, it only starts counting values from the Replacement date, see figure 1. Figure 2 at end of Date range. (measures above table for reference).&lt;BR /&gt;&lt;BR /&gt;So the measure on the right gets the numbers right, but is unable to split it by ClassStructure.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 08:43:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-filter-table-based-on-2-date-fields-purchase-disposal/m-p/2624413#M76590</guid>
      <dc:creator>REWINDER</dc:creator>
      <dc:date>2022-07-07T08:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: Measure to filter table based on 2 date fields (purchase, disposal)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-filter-table-based-on-2-date-fields-purchase-disposal/m-p/2624510#M76595</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="408748" data-lia-user-login="REWINDER" class="lia-mention lia-mention-user"&gt;REWINDER&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;I assume the active relationship is with the&amp;nbsp;FleetActivity[PurchaseDate] coulmn, then please try&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;#Vehicles Active =
CALCULATE (
    COUNTROWS ( FleetActivity ),
    FleetActivity[PurchaseDate] &amp;lt;= MAX ( dimDate2[Date_pk] ),
    FleetActivity[ReplacementDate] &amp;gt;= MIN ( dimDate2[Date_pk] ),
    CROSSFILTER ( FleetActivity[PurchaseDate], dimDate2[Date_pk], NONE )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 09:10:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-filter-table-based-on-2-date-fields-purchase-disposal/m-p/2624510#M76595</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-07-07T09:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: Measure to filter table based on 2 date fields (purchase, disposal)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-filter-table-based-on-2-date-fields-purchase-disposal/m-p/2626282#M76660</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;Thank you for the suggestion, but this solution too only counts total vehicles, and does not separate per Type.&lt;BR /&gt;Attempting to make a hybrid out of the three measures now.&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;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2022 22:03:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-filter-table-based-on-2-date-fields-purchase-disposal/m-p/2626282#M76660</guid>
      <dc:creator>REWINDER</dc:creator>
      <dc:date>2022-07-07T22:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: Measure to filter table based on 2 date fields (purchase, disposal)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-filter-table-based-on-2-date-fields-purchase-disposal/m-p/2627049#M76702</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="408748" data-lia-user-login="REWINDER" class="lia-mention lia-mention-user"&gt;REWINDER&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Would you please provide sample data and on the same screenshot above manually type the correct expected results?&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2022 07:56:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-filter-table-based-on-2-date-fields-purchase-disposal/m-p/2627049#M76702</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-07-08T07:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: Measure to filter table based on 2 date fields (purchase, disposal)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-filter-table-based-on-2-date-fields-purchase-disposal/m-p/2629919#M76889</link>
      <description>&lt;P&gt;SOLUTION:&lt;BR /&gt;&lt;BR /&gt;1. remove connections to date table, then:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;#ClassActiveCount = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;-- Calculate active totals&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;currentDate&lt;/SPAN&gt;&lt;SPAN&gt; =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt; ( &lt;/SPAN&gt;&lt;SPAN&gt;dimDate2[Date_pk]&lt;/SPAN&gt;&lt;SPAN&gt; ) &lt;/SPAN&gt;&lt;SPAN&gt;-- Saves the last visible date&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;Var&lt;/SPAN&gt; &lt;SPAN&gt;MinCurrentDate&lt;/SPAN&gt;&lt;SPAN&gt; =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;MIN&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;SPAN&gt;dimDate2[Date_pk]&lt;/SPAN&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;SPAN&gt;-- Saves first visible date&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;COUNTROWS&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;FleetActivity&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;-- Computes Active count&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;FleetActivity&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;SPAN&gt;FleetActivity[PurchaseDate]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;lt;= &lt;/SPAN&gt;&lt;SPAN&gt;currentDate&lt;/SPAN&gt; &lt;SPAN&gt;-- Where Start date is before the last visible date&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;amp;&amp;amp; (&lt;/SPAN&gt;&lt;SPAN&gt;FleetActivity[ReplacementDate]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;gt; &lt;/SPAN&gt;&lt;SPAN&gt;MinCurrentDate&lt;/SPAN&gt; &lt;SPAN&gt;-- Where End date is after the last visible date&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;|| &lt;/SPAN&gt;&lt;SPAN&gt;FleetActivity[ReplacementDate]&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;BLANK&lt;/SPAN&gt;&lt;SPAN&gt;()) &lt;/SPAN&gt;&lt;SPAN&gt;-- -- Where date is null&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 11 Jul 2022 06:32:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-to-filter-table-based-on-2-date-fields-purchase-disposal/m-p/2629919#M76889</guid>
      <dc:creator>REWINDER</dc:creator>
      <dc:date>2022-07-11T06:32:54Z</dc:date>
    </item>
  </channel>
</rss>

