<?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 Equivalent of max_by() in DAX? in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Equivalent-of-max-by-in-DAX/m-p/3298212#M122931</link>
    <description>&lt;P&gt;In some SQL there is a function max_by(maxed_value, return_value). It basically finds the maximum value of a column (maxed_value) but then returns the value of column (return_value) of the matching row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there an equivalant in DAX, or what is the most efficient way to reproduce the same?&lt;/P&gt;</description>
    <pubDate>Thu, 22 Jun 2023 15:50:39 GMT</pubDate>
    <dc:creator>crispybc</dc:creator>
    <dc:date>2023-06-22T15:50:39Z</dc:date>
    <item>
      <title>Equivalent of max_by() in DAX?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Equivalent-of-max-by-in-DAX/m-p/3298212#M122931</link>
      <description>&lt;P&gt;In some SQL there is a function max_by(maxed_value, return_value). It basically finds the maximum value of a column (maxed_value) but then returns the value of column (return_value) of the matching row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there an equivalant in DAX, or what is the most efficient way to reproduce the same?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2023 15:50:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Equivalent-of-max-by-in-DAX/m-p/3298212#M122931</guid>
      <dc:creator>crispybc</dc:creator>
      <dc:date>2023-06-22T15:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: Equivalent of max_by() in DAX?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Equivalent-of-max-by-in-DAX/m-p/3299050#M122959</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="281109" data-lia-user-login="crispybc" class="lia-mention lia-mention-user"&gt;crispybc&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the documentation on MAX_BY, I see that in the case of multiple matching rows, an arbitrary value from the&amp;nbsp;&lt;STRONG&gt;return_value &lt;/STRONG&gt;column&amp;nbsp;is returned. In the below code, I have used MAX to return such an arbitrary value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Option 1:&lt;/STRONG&gt; If &lt;STRONG&gt;return_value&lt;/STRONG&gt; is never blank, a close equivalent could be to use LASTNONBLANKVALUE:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;LASTNONBLANKVALUE (
    YourTable[maxed_value],
    MAX ( YourTable[return_value] )
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that CALCULATE is not required for the 2nd argument due to automatic&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Option 2:&lt;/STRONG&gt;&amp;nbsp;You could write this, which would allow for blank values of &lt;STRONG&gt;return_value:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;CALCULATE (
    MAX ( YourTable[return_value] ),
    LASTNONBLANK ( YourTable[maxed_value], 0 ) -- filter corresponding to max value
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are certainly other ways to formulate this but these are the most straightforward that come to mind.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2023 03:30:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Equivalent-of-max-by-in-DAX/m-p/3299050#M122959</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2023-06-23T03:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: Equivalent of max_by() in DAX?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Equivalent-of-max-by-in-DAX/m-p/3299194#M122976</link>
      <description>&lt;P&gt;&lt;SPAN&gt;In Dax function ,&amp;nbsp; MAX function is used to find maximum of value following is the formula to find maximim value :&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;MaxByReturn =&lt;BR /&gt;VAR MaxValue = MAX(Table[maxed_value])&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE( MAX(Table[return_value]), Table[maxed_value] = MaxValue )&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jun 2023 06:26:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Equivalent-of-max-by-in-DAX/m-p/3299194#M122976</guid>
      <dc:creator>devanshi</dc:creator>
      <dc:date>2023-06-23T06:26:18Z</dc:date>
    </item>
  </channel>
</rss>

