<?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: Replacing EARLIER functionality to work in a measure in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-EARLIER-functionality-to-work-in-a-measure/m-p/4053791#M160874</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="462806" data-lia-user-login="Oodi" class="lia-mention lia-mention-user"&gt;Oodi&lt;/a&gt;&amp;nbsp;, Try using below measure&lt;/P&gt;
&lt;P&gt;HomeGameNumber = &lt;BR /&gt;VAR CurrentHomeTeam = MAX(TeamSchedule_[HomeTeam])&lt;BR /&gt;VAR CurrentGameDate = MAX(TeamSchedule_[gameDate])&lt;BR /&gt;RETURN&lt;BR /&gt;RANKX(&lt;BR /&gt;FILTER(&lt;BR /&gt;TeamSchedule_,&lt;BR /&gt;TeamSchedule_[HomeTeam] = CurrentHomeTeam&lt;BR /&gt;),&lt;BR /&gt;TeamSchedule_[gameDate],&lt;BR /&gt;,&lt;BR /&gt;ASC,&lt;BR /&gt;DENSE&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HomeGameNumberPerSeason = &lt;BR /&gt;VAR CurrentHomeTeam = MAX(TeamSchedule_[HomeTeam])&lt;BR /&gt;VAR CurrentGameDate = MAX(TeamSchedule_[gameDate])&lt;BR /&gt;VAR CurrentSeason = MAX(TeamSchedule_[season])&lt;BR /&gt;RETURN&lt;BR /&gt;RANKX(&lt;BR /&gt;FILTER(&lt;BR /&gt;TeamSchedule_,&lt;BR /&gt;TeamSchedule_[HomeTeam] = CurrentHomeTeam &amp;amp;&amp;amp;&lt;BR /&gt;TeamSchedule_[season] = CurrentSeason&lt;BR /&gt;),&lt;BR /&gt;TeamSchedule_[gameDate],&lt;BR /&gt;,&lt;BR /&gt;ASC,&lt;BR /&gt;DENSE&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FinalHomeGameNumber = &lt;BR /&gt;IF(&lt;BR /&gt;ISFILTERED(AuxSeason[Season]),&lt;BR /&gt;[HomeGameNumberPerSeason],&lt;BR /&gt;[HomeGameNumber]&lt;BR /&gt;)&lt;/P&gt;</description>
    <pubDate>Mon, 22 Jul 2024 10:47:56 GMT</pubDate>
    <dc:creator>bhanu_gautam</dc:creator>
    <dc:date>2024-07-22T10:47:56Z</dc:date>
    <item>
      <title>Replacing EARLIER functionality to work in a measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-EARLIER-functionality-to-work-in-a-measure/m-p/4053736#M160871</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;BR /&gt;There was already existing topics about this subject but so far had no success with them.&lt;BR /&gt;&lt;BR /&gt;I would like to rank teams with selected season and gamedate with the following way:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR _HomeGameNumber =
// Game number based on gamedate only with no season condition
RANKX(FILTER(TeamSchedule_, TeamSchedule_[HomeTeam] = EARLIER(TeamSchedule_[HomeTeam])), TeamSchedule_[gameDate], , ASC, Dense)

VAR _HomeGameNumberPerSeason =
// Game number based on gamedate and season 
RANKX(FILTER(TeamSchedule_, TeamSchedule_[HomeTeam] = EARLIER(TeamSchedule_[HomeTeam]) &amp;amp;&amp;amp; TeamSchedule_[season] = EARLIER(TeamSchedule_[season])), TeamSchedule_[gameDate], , ASC, Dense)

RETURN
//The Measure should be able to switch between the two whether season is filtered 
//or not which is not possible with calculated column like below:
IF(ISFILTERED(AuxSeason[Season]),
_HomeGameNumberPerSeason,
_HomeGameNumber)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;The goal here would be to replace the EARLIER() function to use in a measure. Would this work somehow with MAX() in a measure?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2024 10:23:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-EARLIER-functionality-to-work-in-a-measure/m-p/4053736#M160871</guid>
      <dc:creator>Oodi</dc:creator>
      <dc:date>2024-07-22T10:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing EARLIER functionality to work in a measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-EARLIER-functionality-to-work-in-a-measure/m-p/4053791#M160874</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="462806" data-lia-user-login="Oodi" class="lia-mention lia-mention-user"&gt;Oodi&lt;/a&gt;&amp;nbsp;, Try using below measure&lt;/P&gt;
&lt;P&gt;HomeGameNumber = &lt;BR /&gt;VAR CurrentHomeTeam = MAX(TeamSchedule_[HomeTeam])&lt;BR /&gt;VAR CurrentGameDate = MAX(TeamSchedule_[gameDate])&lt;BR /&gt;RETURN&lt;BR /&gt;RANKX(&lt;BR /&gt;FILTER(&lt;BR /&gt;TeamSchedule_,&lt;BR /&gt;TeamSchedule_[HomeTeam] = CurrentHomeTeam&lt;BR /&gt;),&lt;BR /&gt;TeamSchedule_[gameDate],&lt;BR /&gt;,&lt;BR /&gt;ASC,&lt;BR /&gt;DENSE&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HomeGameNumberPerSeason = &lt;BR /&gt;VAR CurrentHomeTeam = MAX(TeamSchedule_[HomeTeam])&lt;BR /&gt;VAR CurrentGameDate = MAX(TeamSchedule_[gameDate])&lt;BR /&gt;VAR CurrentSeason = MAX(TeamSchedule_[season])&lt;BR /&gt;RETURN&lt;BR /&gt;RANKX(&lt;BR /&gt;FILTER(&lt;BR /&gt;TeamSchedule_,&lt;BR /&gt;TeamSchedule_[HomeTeam] = CurrentHomeTeam &amp;amp;&amp;amp;&lt;BR /&gt;TeamSchedule_[season] = CurrentSeason&lt;BR /&gt;),&lt;BR /&gt;TeamSchedule_[gameDate],&lt;BR /&gt;,&lt;BR /&gt;ASC,&lt;BR /&gt;DENSE&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FinalHomeGameNumber = &lt;BR /&gt;IF(&lt;BR /&gt;ISFILTERED(AuxSeason[Season]),&lt;BR /&gt;[HomeGameNumberPerSeason],&lt;BR /&gt;[HomeGameNumber]&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2024 10:47:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-EARLIER-functionality-to-work-in-a-measure/m-p/4053791#M160874</guid>
      <dc:creator>bhanu_gautam</dc:creator>
      <dc:date>2024-07-22T10:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing EARLIER functionality to work in a measure</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-EARLIER-functionality-to-work-in-a-measure/m-p/4056022#M160960</link>
      <description>&lt;P&gt;Thanks for the suggestion. Tried it out and the measure returns error:&lt;BR /&gt;&lt;BR /&gt;A single value for column 'gameDate' in table 'TeamSchedule_' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.&lt;BR /&gt;&lt;BR /&gt;The error is caused by the RANKX() Expression TeamSchedule_[GameDate] and goes away with&amp;nbsp; SELECTEDVALUE(TeamSchedule_[GameDate]) but this does not return the correct query i.e. the same the calculated column returns using EARLIER().&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2024 09:20:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Replacing-EARLIER-functionality-to-work-in-a-measure/m-p/4056022#M160960</guid>
      <dc:creator>Oodi</dc:creator>
      <dc:date>2024-07-23T09:20:13Z</dc:date>
    </item>
  </channel>
</rss>

