<?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: The last status by person in a scope of all data in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/The-last-status-by-person-in-a-scope-of-all-data/m-p/2012672#M44729</link>
    <description>&lt;LI-CODE lang="csharp"&gt;// I assume that everything is in one
// table. However, this is such a BAD DESIGN
// that it will in the end make you cry
// crocodille's tears if that's the case.
// You should always follow Best Practices
// to make sure that correct formulas will
// always return correct numbers. If you don't
// follow them, you can never be sure if
// the numbers are reliable. You've been
// warned. Please transform one-table design
// into a correct star schema and adjust
// the formula below accordingly.

[Count by LAST Status] =
var SelectedStatuses = 
	DISTINCT( 'Table'[Certification Status] )
var PeopleAndTheirLastStatusInTimeframe =
	ADDCOLUMNS(
		DISTINCT( 'Table'[PersonID] ),
		"@LastStatus",
			CALCULATE(
				MAXX(
					// This TOPN should return 1
					// row if it's true that no
					// person can have different
					// statuses on a single day.
					// If this assumption is not
					// true, you have to make sure
					// that this function returns
					// the row with the last status
					// in the visible timeframe.
					TOPN(1,
						'Table',
						'Table'[Date],
						DESC
					),
					'Table'[Certification Status]
				),
				// You need to remove any filter on this
				// column if you want to get the last
				// status in the timeframe.
				ALL( 'Table'[Certification Status] )
			)
	)
var PeopleCount =
	COUNTROWS(
		FILTER(
			PeopleAndTheirLastStatusInTimeframe,
			[@LastStatus] in SelectedStatuses
		)
	)
return
	PeopleCount&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 12 Aug 2021 09:27:53 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-08-12T09:27:53Z</dc:date>
    <item>
      <title>The last status by person in a scope of all data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/The-last-status-by-person-in-a-scope-of-all-data/m-p/2011023#M44704</link>
      <description>&lt;P&gt;Hi folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I desperately need help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is a visualization that shows certified vs not certified people by date:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Here is the problem: if a person X has both statuses in April, for example, then I get double count of this person:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;What I need is the last person's status by date (so if he was certified in April then he has only certified status in April).&lt;/P&gt;&lt;P&gt;I've tried the following measure that seems to be working:&lt;/P&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;Test_Part =&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;VAR A =&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;CALCULATE (&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;MIN ( 'Table'[Certification Status] ),&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ALLSELECTED ( 'Table'[Certification Status] )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;CALCULATE (&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[# of people],&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;KEEPFILTERS(&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;'Table'[Certification Status] = A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;img /&gt;&lt;P&gt;But when it shows the whole data, then it takes min status as certified for everyone in every month&lt;BR /&gt;&lt;img /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I've tried to use max date, allexcept per person - nothing is working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate any help.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 11 Aug 2021 16:16:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/The-last-status-by-person-in-a-scope-of-all-data/m-p/2011023#M44704</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-08-11T16:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: The last status by person in a scope of all data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/The-last-status-by-person-in-a-scope-of-all-data/m-p/2011466#M44715</link>
      <description>&lt;P&gt;We need some data, or a sample PBIX file of your work so far.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;How to get good help fast. Help us help you.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;A href="https://www.sqlbi.com/blog/alberto/2021/01/22/on-how-to-ask-a-technical-question-if-you-really-want-an-answer/" rel="noopener" target="_blank"&gt;How To Ask A Technical Question If you Really Want An Answer&lt;/A&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" rel="noopener" target="_blank"&gt;How to Get Your Question Answered Quickly&lt;/A&gt; - Give us a good and concise explanation&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" rel="noopener" target="_blank"&gt;How to provide sample data in the Power BI Forum&lt;/A&gt; - Provide data in a table format per the link, or share an Excel/CSV file via OneDrive, Dropbox, etc.. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Aug 2021 00:37:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/The-last-status-by-person-in-a-scope-of-all-data/m-p/2011466#M44715</guid>
      <dc:creator>edhans</dc:creator>
      <dc:date>2021-08-12T00:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: The last status by person in a scope of all data</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/The-last-status-by-person-in-a-scope-of-all-data/m-p/2012672#M44729</link>
      <description>&lt;LI-CODE lang="csharp"&gt;// I assume that everything is in one
// table. However, this is such a BAD DESIGN
// that it will in the end make you cry
// crocodille's tears if that's the case.
// You should always follow Best Practices
// to make sure that correct formulas will
// always return correct numbers. If you don't
// follow them, you can never be sure if
// the numbers are reliable. You've been
// warned. Please transform one-table design
// into a correct star schema and adjust
// the formula below accordingly.

[Count by LAST Status] =
var SelectedStatuses = 
	DISTINCT( 'Table'[Certification Status] )
var PeopleAndTheirLastStatusInTimeframe =
	ADDCOLUMNS(
		DISTINCT( 'Table'[PersonID] ),
		"@LastStatus",
			CALCULATE(
				MAXX(
					// This TOPN should return 1
					// row if it's true that no
					// person can have different
					// statuses on a single day.
					// If this assumption is not
					// true, you have to make sure
					// that this function returns
					// the row with the last status
					// in the visible timeframe.
					TOPN(1,
						'Table',
						'Table'[Date],
						DESC
					),
					'Table'[Certification Status]
				),
				// You need to remove any filter on this
				// column if you want to get the last
				// status in the timeframe.
				ALL( 'Table'[Certification Status] )
			)
	)
var PeopleCount =
	COUNTROWS(
		FILTER(
			PeopleAndTheirLastStatusInTimeframe,
			[@LastStatus] in SelectedStatuses
		)
	)
return
	PeopleCount&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 12 Aug 2021 09:27:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/The-last-status-by-person-in-a-scope-of-all-data/m-p/2012672#M44729</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-08-12T09:27:53Z</dc:date>
    </item>
  </channel>
</rss>

