<?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: DAX formula to show latest client change row in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-show-latest-client-change-row/m-p/736533#M2058</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for taking the time to look into this problem, I appreciate it.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Carl&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jul 2019 12:56:32 GMT</pubDate>
    <dc:creator>harringtonc</dc:creator>
    <dc:date>2019-07-10T12:56:32Z</dc:date>
    <item>
      <title>DAX formula to show latest client change row</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-show-latest-client-change-row/m-p/735218#M1966</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have a DAX formula in Analysis Services:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;=MAXX( FILTER('Client Changes',&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'Client Changes'[dclc_dcli_id]=EARLIER('Client Changes'[dclc_dcli_id])&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; ),&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 'Client Changes'[dclc_id]&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use this formula to get the latest change record ID by grouping by each distinct client. This works fine.&lt;/P&gt;&lt;P&gt;(this ID can then be used to compare the latest value of any client attribute with previous values to report on changes)&lt;/P&gt;&lt;P&gt;I also have a relationship between my Dates table and 'Client Changes'[Valid To Date], which is the date on which each change was made.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In PowerBI I have a date selection filter which filters the client change records based on their Valid To Date. This filter works fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue I have is that I am having trouble getting the Latest Change ID formula above to "see" the date filter, i.e. I only want to show tyhe latest change ID using the client change records filter by the date selection filter not all records.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So what I want to do is to add a date criteria to the filter which will take into account the maximum Valid To Date as specified by the Power BI date filter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Carl&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 11:41:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-show-latest-client-change-row/m-p/735218#M1966</guid>
      <dc:creator>harringtonc</dc:creator>
      <dc:date>2019-07-09T11:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: DAX formula to show latest client change row</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-show-latest-client-change-row/m-p/735248#M1972</link>
      <description>&lt;P&gt;Why are you using EARLIER in your measure even if there is no OUTER row context to reach? What is this filter actually doing:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    FILTER (
        'Client Changes',
        'Client Changes'[dclc_dcli_id] = EARLIER ( 'Client Changes'[dclc_dcli_id] )
    )&lt;/PRE&gt;&lt;P&gt;I think it's doing nothing since this 'Client Changes'[dclc_dcli_id] = EARLIER ( 'Client Changes'[dclc_dcli_id] ) is ALWAYS TRUE.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would this measure not do the same thing as yours?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;MAXX (
    'Client Changes',
    'Client Changes'[dclc_id]
)&lt;BR /&gt;&lt;BR /&gt;// or even this one:&lt;BR /&gt;MAX ( 'Client Changes'[dclc_id] )&lt;/PRE&gt;&lt;P&gt;By the way, this max should honor any filters that you put on 'Client Changes'. So, if your Date table is tied to a date column in 'Client Changes', then the above should return the max dclc_id that's visible in the current context.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P&gt;Darek&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 12:18:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-show-latest-client-change-row/m-p/735248#M1972</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-09T12:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: DAX formula to show latest client change row</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-show-latest-client-change-row/m-p/735392#M1985</link>
      <description>&lt;P&gt;Hi Darek,&lt;/P&gt;&lt;P&gt;Thanks so much for the quick reply.&lt;/P&gt;&lt;P&gt;I'm using EARLIER in the filter to act as a PARTITION BY clause. There are loads of different client records, so without the EARLIER clause then it will return the MAX dclc_id for the entire table, not the MAX dclc_id for each client:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;dclc_id&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;dclc_dcli_id&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Valid From&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Valid To&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;CTY&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Latest Client Record Id&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Current CTY&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Calculated Valid To Date&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;MAX Client Record Id&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2037475&lt;/TD&gt;&lt;TD&gt;161466&lt;/TD&gt;&lt;TD&gt;01/01/1990&lt;/TD&gt;&lt;TD&gt;22/01/2015&lt;/TD&gt;&lt;TD&gt;ITA&lt;/TD&gt;&lt;TD&gt;2037477&lt;/TD&gt;&lt;TD&gt;ITA&lt;/TD&gt;&lt;TD&gt;22/01/2015&lt;/TD&gt;&lt;TD&gt;2118948&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2037476&lt;/TD&gt;&lt;TD&gt;161466&lt;/TD&gt;&lt;TD&gt;23/01/2015&lt;/TD&gt;&lt;TD&gt;28/07/2016&lt;/TD&gt;&lt;TD&gt;GBR&lt;/TD&gt;&lt;TD&gt;2037477&lt;/TD&gt;&lt;TD&gt;ITA&lt;/TD&gt;&lt;TD&gt;28/07/2016&lt;/TD&gt;&lt;TD&gt;2118948&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2037477&lt;/TD&gt;&lt;TD&gt;161466&lt;/TD&gt;&lt;TD&gt;29/07/2016&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;ITA&lt;/TD&gt;&lt;TD&gt;2037477&lt;/TD&gt;&lt;TD&gt;ITA&lt;/TD&gt;&lt;TD&gt;09/07/2019&lt;/TD&gt;&lt;TD&gt;2118948&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above data only shows the record for Client 161466 and the change record 2037477 is the latest change record for this client. What I want to achive in my report is when the user selects a To Date of say 28/07/2016 then the Latest Client Record ID would change to 2037476.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The &lt;STRONG&gt;Latest Client Record ID&lt;/STRONG&gt; column is calculated using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;=MAXX(FILTER('Client Changes'&lt;BR /&gt;            ,'Client Changes'[dclc_dcli_id]=EARLIER('Client Changes'[dclc_dcli_id]&lt;BR /&gt;            )&lt;BR /&gt;     ,'Client Changes'[dclc_id]&lt;BR /&gt;     )&lt;/PRE&gt;&lt;P&gt;Without the EARLIER clause I get the maximum DCLC_ID in the entire table, &lt;STRONG&gt;Client Record Id&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;=MAXX(FILTER('Client Changes'&lt;BR /&gt;            ,'Client Changes'[dclc_dcli_id]='Client Changes'[dclc_dcli_id]&lt;BR /&gt;            )&lt;BR /&gt;     ,'Client Changes'[dclc_id]&lt;BR /&gt;     )&lt;/PRE&gt;&lt;P&gt;I get the same result for your suggestion:&lt;/P&gt;&lt;PRE&gt;=MAXX('Client Changes'
     ,'Client Changes'[dclc_id]
     )&lt;/PRE&gt;&lt;P&gt;I'm pretty new to DAX and Power BI so I could be using completely the wrong technique.&lt;/P&gt;&lt;P&gt;But what I'm trying to achive is to change my Latest Client Id formula to expand the filter to compare something (parameter) to the&amp;nbsp;&lt;STRONG&gt;Calculated Valid To Date&lt;/STRONG&gt; field in order to get the latest client change record on or before the date slected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Carl&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 14:21:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-show-latest-client-change-row/m-p/735392#M1985</guid>
      <dc:creator>harringtonc</dc:creator>
      <dc:date>2019-07-09T14:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: DAX formula to show latest client change row</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-show-latest-client-change-row/m-p/735417#M1988</link>
      <description>&lt;P&gt;Carl, are you talking about DAX measures or calculated columns? I have a feeling the latter is the case...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P&gt;Darek&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 14:39:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-show-latest-client-change-row/m-p/735417#M1988</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-09T14:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: DAX formula to show latest client change row</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-show-latest-client-change-row/m-p/735441#M1990</link>
      <description>&lt;P&gt;Hi Darek,&lt;/P&gt;&lt;P&gt;Yes, these are calculated columns, sorry should have been more specific (complete n00b, only started using PowerBI and Analysis Services last week!).&lt;/P&gt;&lt;P&gt;Is it because they're not setup as Measures that the columns are not date aware?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Carl&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 14:51:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-show-latest-client-change-row/m-p/735441#M1990</guid>
      <dc:creator>harringtonc</dc:creator>
      <dc:date>2019-07-09T14:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: DAX formula to show latest client change row</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-show-latest-client-change-row/m-p/735465#M1993</link>
      <description>&lt;P&gt;No, that's not why I was asking. Bear with me, please. I'll show you the right formula.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P&gt;Darek&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 15:05:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-show-latest-client-change-row/m-p/735465#M1993</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-09T15:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: DAX formula to show latest client change row</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-show-latest-client-change-row/m-p/735626#M2014</link>
      <description>&lt;P&gt;OK.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First of all, for what you want you cannot have a calculated column, only a measure. Here's the first variation of the measure (since I don't know what version you need as it's not clear from your description):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[Latest Client Record ID] =
var __onlyOneClientVisible = HASONEVALUE( 'Client Changes'[dclc_dcli_id] )
var __dateSelected = SELECTEDVALUE( ValidToDateSlicer[Valid To] )
var __latestClientRecordID =
	CALCULATE(
		MAX( 'Client Changes'[dclc_id] ),
		'Client Changes'[Calculated Valid To Date] &amp;lt;= __dateSelected,
		ALLEXCEPT( 'Client Changes', Client Changes'[dclc_dcli_id] )
	)
return
	if( __onlyOneClientVisible, __latestClientRecordID, "Many Clients Visible")&lt;/PRE&gt;&lt;P&gt;Here's another variation:&lt;/P&gt;&lt;PRE&gt;[Latest Client Record ID] =
var __onlyOneClientVisible = HASONEVALUE( 'Client Changes'[dclc_dcli_id] )
var __dateSelected = SELECTEDVALUE( ValidToDateSlicer[Valid To] )
var __latestClientRecordID =
	CALCULATE(
		MAX( 'Client Changes'[dclc_id] ),
		'Client Changes'[Calculated Valid To Date] &amp;lt;= __dateSelected
	)
return
	if( __onlyOneClientVisible, __latestClientRecordID, "Many Clients Visible")&lt;/PRE&gt;&lt;P&gt;The difference between them is that the first does not honour any filters on the 'Client Changes' table (apart from the one on&amp;nbsp;dclc_dcli_id). The other one does honour all filters on the table apart from [Calculated Valid To Date].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There's still another version that does honour all filters, even on [Calculated Valid To Date]:&lt;/P&gt;&lt;PRE&gt;[Latest Client Record ID] =
var __onlyOneClientVisible = HASONEVALUE( 'Client Changes'[dclc_dcli_id] )
var __dateSelected = SELECTEDVALUE( ValidToDateSlicer[Valid To] )
var __latestClientRecordID =
	CALCULATE(
		MAX( 'Client Changes'[dclc_id] ),
		KEEPFILTERS( 'Client Changes'[Calculated Valid To Date] &amp;lt;= __dateSelected )
	)
return
	if( __onlyOneClientVisible, __latestClientRecordID, "Many Clients Visible")&lt;/PRE&gt;&lt;P&gt;Please note that if more than one client is visible in the current context, "Many Clients Visible" will be returned. This is because it makes no sense to calculate latest record id for many clients at the same time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the above to work you need a table&amp;nbsp;ValidToDateSlicer that will store all the dates you'd like to use as the Valid To date that your users would select. Please note that this table should NOT be linked to 'Client Changes' in any way. It's a parameter table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P&gt;Darek&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 17:26:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-show-latest-client-change-row/m-p/735626#M2014</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-09T17:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: DAX formula to show latest client change row</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-show-latest-client-change-row/m-p/736533#M2058</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for taking the time to look into this problem, I appreciate it.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Carl&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2019 12:56:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-formula-to-show-latest-client-change-row/m-p/736533#M2058</guid>
      <dc:creator>harringtonc</dc:creator>
      <dc:date>2019-07-10T12:56:32Z</dc:date>
    </item>
  </channel>
</rss>

