<?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: RANKX Expression for 3 Columns in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-Expression-for-3-Columns/m-p/3273856#M121418</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am not sure how your datamodel looks like, but please check the below picture and the attached pbix file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Count of attribute expected result: =
VAR _currentrowattribute =
    MAX ( Data[Attribute] )
RETURN
    IF (
        HASONEVALUE ( Data[Attribute] ),
        COUNTROWS (
            FILTER (
                ADDCOLUMNS (
                    ALL ( Data ),
                    "@Rank_partion_ID",
                        RANK (
                            skip,
                            ALL ( Data ),
                            ORDERBY ( Data[Value], ASC ),
                            PARTITIONBY ( Data[ID] )
                        )
                ),
                Data[Attribute] = _currentrowattribute
                    &amp;amp;&amp;amp; [@Rank_partion_ID] = 1
            )
        )
    )
&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 08 Jun 2023 03:29:45 GMT</pubDate>
    <dc:creator>Jihwan_Kim</dc:creator>
    <dc:date>2023-06-08T03:29:45Z</dc:date>
    <item>
      <title>RANKX Expression for 3 Columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-Expression-for-3-Columns/m-p/3273567#M121407</link>
      <description>&lt;P&gt;Hi everyone, first post.&amp;nbsp; Using the sample data below (call the table RANKX Test), I want to write a RANKX measure that ranks the Attribute column by the Value column, for each ID column value:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Attribute&lt;/TD&gt;&lt;TD&gt;Value&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;111&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;111&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;112&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;112&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;70&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;113&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;113&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;40&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know how to rank attribute by value, and create a visual level filter for the top ranked attribute:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rank Attributes =&amp;nbsp;IF(RANKX(ALLSELECTED('RANKX Test'[Attribute]),CALCULATE(SUM('RANKX Test'[Value])),,ASC,Dense)&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;=1,1,0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A table with the Attribute column and a column with the COUNT of Attribute values looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attribute&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Count of Attribute&lt;/P&gt;&lt;P&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to add the ID column to the measure, so that the attributes are ranked for each ID.&amp;nbsp; I would want the table above to look like this since A would be the top ranked attribute for two IDs and B would be the top ranked attribute for one ID:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attribute&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Count of Attribute&lt;/P&gt;&lt;P&gt;A&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;2&lt;/P&gt;&lt;P&gt;B&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;1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate any help on this!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2023 23:27:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-Expression-for-3-Columns/m-p/3273567#M121407</guid>
      <dc:creator>Matt1979</dc:creator>
      <dc:date>2023-06-07T23:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: RANKX Expression for 3 Columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-Expression-for-3-Columns/m-p/3273856#M121418</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am not sure how your datamodel looks like, but please check the below picture and the attached pbix file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Count of attribute expected result: =
VAR _currentrowattribute =
    MAX ( Data[Attribute] )
RETURN
    IF (
        HASONEVALUE ( Data[Attribute] ),
        COUNTROWS (
            FILTER (
                ADDCOLUMNS (
                    ALL ( Data ),
                    "@Rank_partion_ID",
                        RANK (
                            skip,
                            ALL ( Data ),
                            ORDERBY ( Data[Value], ASC ),
                            PARTITIONBY ( Data[ID] )
                        )
                ),
                Data[Attribute] = _currentrowattribute
                    &amp;amp;&amp;amp; [@Rank_partion_ID] = 1
            )
        )
    )
&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 08 Jun 2023 03:29:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-Expression-for-3-Columns/m-p/3273856#M121418</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2023-06-08T03:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: RANKX Expression for 3 Columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-Expression-for-3-Columns/m-p/3276663#M121554</link>
      <description>&lt;P&gt;Thanks!&amp;nbsp; That works...&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 13:23:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANKX-Expression-for-3-Columns/m-p/3276663#M121554</guid>
      <dc:creator>Matt1979</dc:creator>
      <dc:date>2023-06-09T13:23:57Z</dc:date>
    </item>
  </channel>
</rss>

