<?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: Create a distinctcount that count just the ID outside my date range in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-distinctcount-that-count-just-the-ID-outside-my-date/m-p/2260240#M54629</link>
    <description>&lt;P&gt;Hi sorry I posted earlier and then realised there was more complexity to the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I've now fully understood and the following will help:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR LatestVisibleDate = MAX(Dwh_D_Tempo[Data]),
VAR EarliestVisibleDate = MIN(Dwh_D_Tempo[Data])

VAR IdsInDateRange = 
	TREATAS ( 
		CALCULATETABLE (
			VALUES ( Dwh_D_Asset[IDassegnatario] ), 
			Dwh_F_Asset[DataInizioValidita]&amp;lt;= LatestVisbleDate
			Dwh_F_Asset[DataFineValidita] &amp;gt;= EarliestVisibleDate
		),	
		Dwh_D_Soggetto[IDPersona] 
	)

VAR AllIds = 
	CALCULATETABLE (
		VALUES ( Dwh_D_Soggetto[IDPersona] ),
		REMOVEFILTERS ( Dwh_D_Soggetto )
	)

VAR IdsOutsideRange = 
	EXCEPT ( 
		AllIds, 
		IdsInDateRange 
	)

RETURN 
	COUNTROWS ( IdsOutsideRange )&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 29 Dec 2021 22:42:38 GMT</pubDate>
    <dc:creator>bcdobbs</dc:creator>
    <dc:date>2021-12-29T22:42:38Z</dc:date>
    <item>
      <title>Create a distinctcount that count just the ID outside my date range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-distinctcount-that-count-just-the-ID-outside-my-date/m-p/2260184#M54623</link>
      <description>&lt;P&gt;Hello to Everyone&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two big problems for create a 2 different measures. The first one. I want calculate the distinct&amp;nbsp; IDUser&amp;nbsp; that are not prensent in my date range.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here my data model&amp;nbsp;&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;The join is&amp;nbsp; &amp;nbsp;Asset[IDassegnatario] with Soggetto[IDPersona]&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want obtain the&amp;nbsp; number of&amp;nbsp; distinct subjet that are not present inside the date range that i selected in the slicer. So if a subject compare inside the date range have to be exluded from the distinctcount.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this dax code :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;distinctCOUNT&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Dwh_D_Soggetto[IdPersona]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt; ( &lt;/SPAN&gt;&lt;SPAN&gt;Dwh_F_Asset&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;not&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Dwh_F_Asset[DataInizioValidita]&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;= &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Dwh_D_Tempo[Data]&lt;/SPAN&gt;&lt;SPAN&gt;)) &amp;amp;&amp;amp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Dwh_F_Asset[DataFineValidita]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;gt;= &lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;MIN&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Dwh_D_Tempo[Data]&lt;/SPAN&gt;&lt;SPAN&gt;)))))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;But with this&amp;nbsp; formula if one of the subject &amp;gt;&amp;gt; [IDPersona] , is present outside my date range condition will be count one time by my starting formula distinctcount.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;So how i can wrote a DAX formula where i distinctcount the subject outside my date range and not included insiede my date Range&amp;nbsp; ? I deal with it since pass week and i can't find a properly solution&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thank you so much for the help&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2021 21:37:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-distinctcount-that-count-just-the-ID-outside-my-date/m-p/2260184#M54623</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-12-29T21:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: Create a distinctcount that count just the ID outside my date range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-distinctcount-that-count-just-the-ID-outside-my-date/m-p/2260240#M54629</link>
      <description>&lt;P&gt;Hi sorry I posted earlier and then realised there was more complexity to the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I've now fully understood and the following will help:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR LatestVisibleDate = MAX(Dwh_D_Tempo[Data]),
VAR EarliestVisibleDate = MIN(Dwh_D_Tempo[Data])

VAR IdsInDateRange = 
	TREATAS ( 
		CALCULATETABLE (
			VALUES ( Dwh_D_Asset[IDassegnatario] ), 
			Dwh_F_Asset[DataInizioValidita]&amp;lt;= LatestVisbleDate
			Dwh_F_Asset[DataFineValidita] &amp;gt;= EarliestVisibleDate
		),	
		Dwh_D_Soggetto[IDPersona] 
	)

VAR AllIds = 
	CALCULATETABLE (
		VALUES ( Dwh_D_Soggetto[IDPersona] ),
		REMOVEFILTERS ( Dwh_D_Soggetto )
	)

VAR IdsOutsideRange = 
	EXCEPT ( 
		AllIds, 
		IdsInDateRange 
	)

RETURN 
	COUNTROWS ( IdsOutsideRange )&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 29 Dec 2021 22:42:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-distinctcount-that-count-just-the-ID-outside-my-date/m-p/2260240#M54629</guid>
      <dc:creator>bcdobbs</dc:creator>
      <dc:date>2021-12-29T22:42:38Z</dc:date>
    </item>
    <item>
      <title>Re: Create a distinctcount that count just the ID outside my date range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-distinctcount-that-count-just-the-ID-outside-my-date/m-p/2260241#M54630</link>
      <description>&lt;P&gt;&lt;STRONG&gt;IdsInDateRange&lt;/STRONG&gt; gets a list of&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;IDassegnatario present inside the date range and uses TREATAS to move them back to the Soggetto dimension.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;AllIds&lt;/STRONG&gt; gets a list of all IDPersona. (Note if you removed the bidirectional filter the caclulate and removefilters wouldn't be needed).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;IdsOutsideRange&lt;/STRONG&gt; gets a list of all ids that are in AllIds but not in IdsInDateRange using EXCEPT.&lt;BR /&gt;&lt;BR /&gt;It then just returns a count of these.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2021 22:46:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-distinctcount-that-count-just-the-ID-outside-my-date/m-p/2260241#M54630</guid>
      <dc:creator>bcdobbs</dc:creator>
      <dc:date>2021-12-29T22:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Create a distinctcount that count just the ID outside my date range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-distinctcount-that-count-just-the-ID-outside-my-date/m-p/2261007#M54679</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="168297" data-lia-user-login="bcdobbs" class="lia-mention lia-mention-user"&gt;bcdobbs&lt;/a&gt;&amp;nbsp; mate thank you so much really !!! It's really smooth your Dax formula i never saw and used the treatas formula, look like really massive.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will remove the bideriction in order to have just :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;AllIds&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;VALUES&lt;/SPAN&gt;&lt;SPAN&gt; ( &lt;/SPAN&gt;&lt;SPAN&gt;Dwh_D_Soggetto[IDPersona]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;In this way i can filter directly from&amp;nbsp;Dwh_D_Soggetto&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Dec 2021 11:21:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-distinctcount-that-count-just-the-ID-outside-my-date/m-p/2261007#M54679</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-12-30T11:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: Create a distinctcount that count just the ID outside my date range</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-distinctcount-that-count-just-the-ID-outside-my-date/m-p/2261056#M54680</link>
      <description>&lt;P&gt;Perfect.&lt;/P&gt;&lt;P&gt;Glad it works. I think you can actually remove the TREATAS, thought I needed it to make the EXCEPT work but you don't.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Dec 2021 11:52:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Create-a-distinctcount-that-count-just-the-ID-outside-my-date/m-p/2261056#M54680</guid>
      <dc:creator>bcdobbs</dc:creator>
      <dc:date>2021-12-30T11:52:31Z</dc:date>
    </item>
  </channel>
</rss>

