<?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: COUNT DISTINCT users ID, but only select their last result in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNT-DISTINCT-users-ID-but-only-select-their-last-result/m-p/1290966#M22178</link>
    <description>&lt;LI-CODE lang="csharp"&gt;// You have to have a Calendar table
// that's DISCONNECTED from the T table.
// Now, this is a measure that for a
// selected period of time from Calendar
// tells you the number of 'Conform'
// emps at their last evaluation BEFORE OR ON
// the last day of the selected period.
// I assume an employee is fully identified
// by UserID and that each employee can only
// have 1 entry on any specific day. This
// measure does fully respond to slicers, so
// be careful to correctly interpret the results.

[# Conform Emps] =
var __lastVisibleDate = MAX( Calendar[Date] )
var __empsWithConformAsLastEval =
	FILTER(
		VALUES( T[UserID] ),
		var __latestRecordForUser =
			CALCULATETABLE(
				TOPN(1,
					filter(
						T,
						T[DT_EVAL] &amp;lt;= __lastVisibleDate
					),
					T[DT_EVAL],
					DESC
				)
			)
		var __conformityIsConform =
			NOT ISEMPTY(
				FILTER(
					__latestRecordForUser,
					T[Conformity] = "conform"
				)
			)
		return
			__conformityIsConform
	)
return
	COUNTROWS( __empsWithConformAsLastEval )&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 12 Aug 2020 15:45:05 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-08-12T15:45:05Z</dc:date>
    <item>
      <title>COUNT DISTINCT users ID, but only select their last result</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNT-DISTINCT-users-ID-but-only-select-their-last-result/m-p/1285207#M21982</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have someting of the kind :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;UserID&lt;/TD&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;DT_EVAL&lt;/TD&gt;&lt;TD&gt;Conformity&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Markov67&lt;/TD&gt;&lt;TD&gt;Andrei Markov&lt;/TD&gt;&lt;TD&gt;2020-08-10&lt;/TD&gt;&lt;TD&gt;conform&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Markov67&lt;/TD&gt;&lt;TD&gt;Andrei Markov&lt;/TD&gt;&lt;TD&gt;2020-08-08&lt;/TD&gt;&lt;TD&gt;not conform&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Plekanec14&lt;/TD&gt;&lt;TD&gt;Thomas Plekanec&lt;/TD&gt;&lt;TD&gt;2020-08-10&lt;/TD&gt;&lt;TD&gt;not conform&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want my measure to return me : 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Reason : I only want the last evaluation of every user.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2020 13:22:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNT-DISTINCT-users-ID-but-only-select-their-last-result/m-p/1285207#M21982</guid>
      <dc:creator>NumeroENAP</dc:creator>
      <dc:date>2020-08-12T13:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: COUNT DISTINCT users ID, but only select their last result</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNT-DISTINCT-users-ID-but-only-select-their-last-result/m-p/1285229#M21983</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="165118" data-lia-user-login="NumeroENAP" class="lia-mention lia-mention-user"&gt;NumeroENAP&lt;/a&gt;&amp;nbsp;- Perhaps use MAX to get the greatest date in the table and then FILTER down to that date, use DISTINCT and COUNTROWS, so like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Measure = COUNTROWS(DISTINCT(FILTER('Table',[Date] = MAX('Table'[Date])))&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 18:40:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNT-DISTINCT-users-ID-but-only-select-their-last-result/m-p/1285229#M21983</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-08-10T18:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: COUNT DISTINCT users ID, but only select their last result</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNT-DISTINCT-users-ID-but-only-select-their-last-result/m-p/1285388#M21996</link>
      <description>&lt;DIV&gt;&lt;SPAN&gt;Ok, it's nice, and it's defenitely the closest I've been from the solution, but, it's not exactly what I need.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;By exemple, if I need to group it by conformity :&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Conformity&lt;/TD&gt;&lt;TD&gt;Distinct User&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Conform&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Not conform&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, with what you gave me, even if it gives me a table with what I need (raw), but I can't group it the way I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am I clear enough?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 10 Aug 2020 20:18:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNT-DISTINCT-users-ID-but-only-select-their-last-result/m-p/1285388#M21996</guid>
      <dc:creator>NumeroENAP</dc:creator>
      <dc:date>2020-08-10T20:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: COUNT DISTINCT users ID, but only select their last result</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNT-DISTINCT-users-ID-but-only-select-their-last-result/m-p/1286197#M22027</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="165118" data-lia-user-login="NumeroENAP" class="lia-mention lia-mention-user"&gt;NumeroENAP&lt;/a&gt;&amp;nbsp;- Wait, now I am confused, where did conform/not comform come from? Perhaps we should back-up.&amp;nbsp;Please first check if your issue is a common issue listed here: &lt;A href="https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Also, please see this post regarding How to Get Your Question Answered Quickly: &lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;The most important parts are:&lt;BR /&gt;1. Sample data as text, use the table tool in the editing bar&lt;BR /&gt;2. Expected output from sample data&lt;BR /&gt;3. Explanation in words of how to get from 1. to 2.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Aug 2020 04:41:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNT-DISTINCT-users-ID-but-only-select-their-last-result/m-p/1286197#M22027</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-08-11T04:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: COUNT DISTINCT users ID, but only select their last result</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNT-DISTINCT-users-ID-but-only-select-their-last-result/m-p/1287615#M22086</link>
      <description>&lt;P&gt;I need to have a measure that tells me exactly :&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;How many employees have a «conform» or «not conform» evaluation at their last evaluation ;&lt;/LI&gt;&lt;LI&gt;I also need that measure to be flexible, so I can use it in others visualisation, with other columns of the same table.&amp;nbsp;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;UserID&lt;/TD&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;DT_EVAL&lt;/TD&gt;&lt;TD&gt;Conformity&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Markov67&lt;/TD&gt;&lt;TD&gt;Andrei Markov&lt;/TD&gt;&lt;TD&gt;2020-08-10&lt;/TD&gt;&lt;TD&gt;Conform&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Markov67&lt;/TD&gt;&lt;TD&gt;Andrei Markov&lt;/TD&gt;&lt;TD&gt;2020-08-08&lt;/TD&gt;&lt;TD&gt;Not conform&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Plekanec14&lt;/TD&gt;&lt;TD&gt;Thomas Plekanec&lt;/TD&gt;&lt;TD&gt;2020-08-10&lt;/TD&gt;&lt;TD&gt;Not conform&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2020 13:24:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNT-DISTINCT-users-ID-but-only-select-their-last-result/m-p/1287615#M22086</guid>
      <dc:creator>NumeroENAP</dc:creator>
      <dc:date>2020-08-12T13:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: COUNT DISTINCT users ID, but only select their last result</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNT-DISTINCT-users-ID-but-only-select-their-last-result/m-p/1290966#M22178</link>
      <description>&lt;LI-CODE lang="csharp"&gt;// You have to have a Calendar table
// that's DISCONNECTED from the T table.
// Now, this is a measure that for a
// selected period of time from Calendar
// tells you the number of 'Conform'
// emps at their last evaluation BEFORE OR ON
// the last day of the selected period.
// I assume an employee is fully identified
// by UserID and that each employee can only
// have 1 entry on any specific day. This
// measure does fully respond to slicers, so
// be careful to correctly interpret the results.

[# Conform Emps] =
var __lastVisibleDate = MAX( Calendar[Date] )
var __empsWithConformAsLastEval =
	FILTER(
		VALUES( T[UserID] ),
		var __latestRecordForUser =
			CALCULATETABLE(
				TOPN(1,
					filter(
						T,
						T[DT_EVAL] &amp;lt;= __lastVisibleDate
					),
					T[DT_EVAL],
					DESC
				)
			)
		var __conformityIsConform =
			NOT ISEMPTY(
				FILTER(
					__latestRecordForUser,
					T[Conformity] = "conform"
				)
			)
		return
			__conformityIsConform
	)
return
	COUNTROWS( __empsWithConformAsLastEval )&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 12 Aug 2020 15:45:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNT-DISTINCT-users-ID-but-only-select-their-last-result/m-p/1290966#M22178</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-12T15:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: COUNT DISTINCT users ID, but only select their last result</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNT-DISTINCT-users-ID-but-only-select-their-last-result/m-p/1291741#M22240</link>
      <description>&lt;P&gt;In the end, I went with a non-performing option, but it works great.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First of all, I created a calculated column :&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;LAST_EVAL_DT = VAR LastID = RES[ID]&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;MAXX(&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;FILTER( ALL('RES') , 'RES'[ID] = LastID) ,&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;'RES'[DT_EVAL])&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&lt;SPAN&gt;After that, I created a column that I could filter easily with a COUNTROWS :&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;SPAN&gt;QC = IF (RES[DT_EVAL] = RES[LAST_EVAL_DT] , 1 , BLANK() )&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="3"&gt;&lt;SPAN&gt;Thank you all for your efforts.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 12 Aug 2020 23:27:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/COUNT-DISTINCT-users-ID-but-only-select-their-last-result/m-p/1291741#M22240</guid>
      <dc:creator>NumeroENAP</dc:creator>
      <dc:date>2020-08-12T23:27:14Z</dc:date>
    </item>
  </channel>
</rss>

