<?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 - Top 5 values in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Top-5-values/m-p/3800564#M156444</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="712365" data-lia-user-login="Ahsan_" class="lia-mention lia-mention-user"&gt;Ahsan_&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. The reason you are getting the full total in the total row is because there is no concept of a manager filtering this value so there is nothing to rank. To remedy this you can create a new measure that iterates over the all the values of manager and adds them up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Top 5 Managers Enhanced =
SUMX(
    VALUES( Store[Manager Name] ),
    [Top 5 managers]
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. When you add Store onto the axis that adds store to the filter context of the rank. All managers will be the top ranked for their store (assuming one manager per store) so they all show. I don't know the intricacies of the model but you could extend the above to state&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;Top 5 Managers Enhanced =
CALCULATE(
    SUMX(
        VALUES( Store[Manager Name] ),
        [Top 5 managers]
    ),
    ALL( Store[Store Name] )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've assumed there that Store Name is in the same Store table as manager.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want it all in the same measure you could copy paste your original code in but make sure to wrap it in a CALCULATE so that context transition takes place&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Top 5 Managers Enhanced =
CALCULATE(
    SUMX(
        VALUES( Store[Manager Name] ),
        CALCULATE(
            VAR ranking = RANKX(ALL(Store[Manager Name]),[Sales Commission],,DESC)
            RETURN
            IF(ranking &amp;lt;=5,[Sales Commission])
        )
    ),
    ALL( Store[Store Name] )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it helps,&lt;/P&gt;&lt;P&gt;Kris&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>Sat, 30 Mar 2024 22:07:46 GMT</pubDate>
    <dc:creator>kriscoupe</dc:creator>
    <dc:date>2024-03-30T22:07:46Z</dc:date>
    <item>
      <title>Rankx - Top 5 values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Top-5-values/m-p/3800557#M156443</link>
      <description>&lt;P&gt;Hello there!&lt;BR /&gt;I have used the below dax expression for Top 5 Managers by Commision, which worked,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Top &lt;/SPAN&gt;&lt;SPAN&gt;5&lt;/SPAN&gt;&lt;SPAN&gt; managers =&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;ranking&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;RANKX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ALL&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Store&lt;/SPAN&gt;&lt;SPAN&gt;[Manager Name]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;[Sales Commission]&lt;/SPAN&gt;&lt;SPAN&gt;,,&lt;/SPAN&gt;&lt;SPAN&gt;DESC&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;IF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ranking&lt;/SPAN&gt;&lt;SPAN&gt; &amp;lt;=&lt;/SPAN&gt;&lt;SPAN&gt;5&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;[Sales Commission]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;BR /&gt;&lt;BR /&gt;&lt;img /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;Above is the result, which is fine, but there are two problems:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Total: It shows the total for the whole column, not for the top 5 values. How do I fix this?&lt;/LI&gt;&lt;LI&gt;I want to add another column for the store name, which shows the store name of each manager. However, when I add the column, it starts showing the data for all the managers instead of the top 5 managers. How can I add the store name column without ruining the top 5 rank?&lt;/LI&gt;&lt;/OL&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 30 Mar 2024 21:30:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Top-5-values/m-p/3800557#M156443</guid>
      <dc:creator>Ahsan_</dc:creator>
      <dc:date>2024-03-30T21:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx - Top 5 values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Top-5-values/m-p/3800564#M156444</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="712365" data-lia-user-login="Ahsan_" class="lia-mention lia-mention-user"&gt;Ahsan_&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. The reason you are getting the full total in the total row is because there is no concept of a manager filtering this value so there is nothing to rank. To remedy this you can create a new measure that iterates over the all the values of manager and adds them up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Top 5 Managers Enhanced =
SUMX(
    VALUES( Store[Manager Name] ),
    [Top 5 managers]
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. When you add Store onto the axis that adds store to the filter context of the rank. All managers will be the top ranked for their store (assuming one manager per store) so they all show. I don't know the intricacies of the model but you could extend the above to state&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;Top 5 Managers Enhanced =
CALCULATE(
    SUMX(
        VALUES( Store[Manager Name] ),
        [Top 5 managers]
    ),
    ALL( Store[Store Name] )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've assumed there that Store Name is in the same Store table as manager.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want it all in the same measure you could copy paste your original code in but make sure to wrap it in a CALCULATE so that context transition takes place&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Top 5 Managers Enhanced =
CALCULATE(
    SUMX(
        VALUES( Store[Manager Name] ),
        CALCULATE(
            VAR ranking = RANKX(ALL(Store[Manager Name]),[Sales Commission],,DESC)
            RETURN
            IF(ranking &amp;lt;=5,[Sales Commission])
        )
    ),
    ALL( Store[Store Name] )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it helps,&lt;/P&gt;&lt;P&gt;Kris&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>Sat, 30 Mar 2024 22:07:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Top-5-values/m-p/3800564#M156444</guid>
      <dc:creator>kriscoupe</dc:creator>
      <dc:date>2024-03-30T22:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx - Top 5 values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Top-5-values/m-p/3800587#M156445</link>
      <description>&lt;P&gt;It worked like magic! Thanks&lt;/P&gt;</description>
      <pubDate>Sun, 31 Mar 2024 00:01:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Top-5-values/m-p/3800587#M156445</guid>
      <dc:creator>Ahsan_</dc:creator>
      <dc:date>2024-03-31T00:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx - Top 5 values</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Top-5-values/m-p/4004847#M156446</link>
      <description>&lt;P&gt;thank you&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jun 2024 03:45:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Top-5-values/m-p/4004847#M156446</guid>
      <dc:creator>makoknam</dc:creator>
      <dc:date>2024-06-22T03:45:56Z</dc:date>
    </item>
  </channel>
</rss>

