<?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 Top N by different parameters in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Top-N-by-different-parameters/m-p/49682#M156409</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a dataset with very simple data: ProductID, Region, Value, Category. I wanted to rank the Products by their Value. So I did the following:&lt;/P&gt;&lt;P&gt;Create Measures:&lt;/P&gt;&lt;P&gt;1. Total_Budget = SUM('Projects'[Value])&lt;/P&gt;&lt;P&gt;2. Rank = RANKX(ALLSELECTED(Projects);[Total_Budget];;DESC;Dense)&lt;/P&gt;&lt;P&gt;And it works. When I create a table diagram, they are ranked correctly and when I use a slicer and filter the region, then the data is refreshed correctly:&lt;/P&gt;&lt;P&gt;&lt;img&gt;﻿&lt;/img&gt;&lt;/P&gt;&lt;P&gt;Now I want to remove the ProductID column from the diagram and ranked again by their values but by the region, so that I get the regions ranked by their values (of course it is the same Value Column as before)&lt;/P&gt;&lt;P&gt;But removing the ProductID column results in a different result not correctly sorted and ranked:&lt;/P&gt;&lt;P&gt;&lt;img&gt;﻿&lt;/img&gt;&lt;/P&gt;&lt;P&gt;How can I accomplish this? What am I doing wrong?&lt;/P&gt;</description>
    <pubDate>Wed, 13 Jul 2016 09:34:21 GMT</pubDate>
    <dc:creator>MbProg</dc:creator>
    <dc:date>2016-07-13T09:34:21Z</dc:date>
    <item>
      <title>Top N by different parameters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Top-N-by-different-parameters/m-p/49682#M156409</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a dataset with very simple data: ProductID, Region, Value, Category. I wanted to rank the Products by their Value. So I did the following:&lt;/P&gt;&lt;P&gt;Create Measures:&lt;/P&gt;&lt;P&gt;1. Total_Budget = SUM('Projects'[Value])&lt;/P&gt;&lt;P&gt;2. Rank = RANKX(ALLSELECTED(Projects);[Total_Budget];;DESC;Dense)&lt;/P&gt;&lt;P&gt;And it works. When I create a table diagram, they are ranked correctly and when I use a slicer and filter the region, then the data is refreshed correctly:&lt;/P&gt;&lt;P&gt;&lt;img&gt;﻿&lt;/img&gt;&lt;/P&gt;&lt;P&gt;Now I want to remove the ProductID column from the diagram and ranked again by their values but by the region, so that I get the regions ranked by their values (of course it is the same Value Column as before)&lt;/P&gt;&lt;P&gt;But removing the ProductID column results in a different result not correctly sorted and ranked:&lt;/P&gt;&lt;P&gt;&lt;img&gt;﻿&lt;/img&gt;&lt;/P&gt;&lt;P&gt;How can I accomplish this? What am I doing wrong?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2016 09:34:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Top-N-by-different-parameters/m-p/49682#M156409</guid>
      <dc:creator>MbProg</dc:creator>
      <dc:date>2016-07-13T09:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: Top N by different parameters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Top-N-by-different-parameters/m-p/4908896#M186565</link>
      <description>&lt;P&gt;Hi&lt;SPAN&gt;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="8385" data-lia-user-login="MbProg" class="lia-mention lia-mention-user"&gt;MbProg&lt;/a&gt;,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I hope you are doing well today&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="lia-unicode-emoji"&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;SPAN class="lia-unicode-emoji"&gt;&lt;span class="lia-unicode-emoji" title=":red_heart:"&gt;❤️&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are two solutions you can use to fix the rank issue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Solution 1:&amp;nbsp;Rank by Region explicitly&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Total_Budget :=
SUM ( Projects[Value] )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Rank by Region :=
RANKX (
    ALLSELECTED ( Projects[Region] ),
    [Total_Budget],
    ,
    DESC,
    DENSE
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Key takeaway (important):&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;ALLSELECTED(Projects[Region]) → ranking list = Regions&lt;/LI&gt;&lt;LI&gt;Total_Budget → evaluates Value per Region&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;Ranking now matches the table granularity&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Works with slicers&lt;/LI&gt;&lt;LI&gt;Works when ProductID is removed&lt;/LI&gt;&lt;LI&gt;Correct sorting &amp;amp; ranking&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;Sort: By Rank by Region (ascending) in Table / Visual&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Solution 2: Dynamic Ranking&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If you want dynamic behavior (rank by Product when ProductID is present, otherwise by Region):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Total_Budget :=
SUM ( Projects[Value] )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Dynamic Rank :=
IF (
    ISINSCOPE ( Projects[ProductID] ),
    RANKX (
        ALLSELECTED ( Projects[ProductID] ),
        [Total_Budget],
        ,
        DESC,
        DENSE
    ),
    RANKX (
        ALLSELECTED ( Projects[Region] ),
        [Total_Budget],
        ,
        DESC,
        DENSE
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Key takeaway (important):&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;RANKX must always rank over the same column(s) used in the visual grouping.&lt;/P&gt;&lt;P&gt;If the visual shows:&lt;/P&gt;&lt;P&gt;Products → rank Products&lt;/P&gt;&lt;P&gt;Regions → rank Regions&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Final Implementation Screenshot:&lt;/STRONG&gt;&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;P&gt;&amp;nbsp;&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this answer helped, kindly give &lt;FONT color="#993300"&gt;&lt;STRONG&gt;Kudos&lt;/STRONG&gt;&lt;/FONT&gt; and &lt;STRONG&gt;&lt;FONT color="#993300"&gt;mark&lt;/FONT&gt; &lt;FONT color="#993300"&gt;it as the Accepted Solution&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;to help other members find it more quickly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Vaibhav Mahajan&lt;/P&gt;&lt;P&gt;LinkedIn: &lt;A href="https://www.linkedin.com/in/vaibhavnmahajan" target="_self"&gt;https://www.linkedin.com/in/vaibhavnmahajan&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Dec 2025 13:25:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Top-N-by-different-parameters/m-p/4908896#M186565</guid>
      <dc:creator>vaibhavmahajan</dc:creator>
      <dc:date>2025-12-26T13:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: Top N by different parameters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Top-N-by-different-parameters/m-p/4911896#M186621</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="8385" data-lia-user-login="MbProg" class="lia-mention lia-mention-user"&gt;MbProg&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try below measure:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Dynamic Rank = 
SWITCH(
    TRUE(),
    ISINSCOPE(Projects[ProductID]), 
        RANKX(
            ALLSELECTED(Projects[ProductID]),
            [Total_Budget],
            ,
            DESC,
            Dense
        ),
    ISINSCOPE(Projects[Region]), 
        RANKX(
            ALLSELECTED(Projects[Region]),
            [Total_Budget],
            ,
            DESC,
            Dense
        ),
    BLANK()
)&lt;/LI-CODE&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;img /&gt;&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://drive.google.com/file/d/1LLTsrxUMZ3SQ7CWfk0Vwf107fR0RbMMs/view?usp=sharing" target="_self"&gt;Sample PBIX&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Please give kudos or mark it as solution once confirmed.&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;Praful&lt;/P&gt;</description>
      <pubDate>Sat, 03 Jan 2026 14:31:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Top-N-by-different-parameters/m-p/4911896#M186621</guid>
      <dc:creator>Praful_Potphode</dc:creator>
      <dc:date>2026-01-03T14:31:49Z</dc:date>
    </item>
  </channel>
</rss>

