<?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 Not working as expected when data is filtered using slicers and filter pane in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Not-working-as-expected-when-data-is-filtered-using/m-p/4351083#M172789</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="408509" data-lia-user-login="powerbiexpert22" class="lia-mention lia-mention-user"&gt;powerbiexpert22&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you filter a specific store in a district, we will again start getting rank 1 for everything . That is my main point of concern.&lt;/P&gt;&lt;P&gt;In a district we want to exclude certain stores .&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 05 Jan 2025 21:01:12 GMT</pubDate>
    <dc:creator>Vivek26</dc:creator>
    <dc:date>2025-01-05T21:01:12Z</dc:date>
    <item>
      <title>Rankx Not working as expected when data is filtered using slicers and filter pane</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Not-working-as-expected-when-data-is-filtered-using/m-p/4350645#M172774</link>
      <description>&lt;DIV&gt;I am facing a challenge with Rankx implementation.&lt;/DIV&gt;&lt;DIV&gt;When I use slicers to filter certain dimensions the rankx starts behaving incorrectly&lt;/DIV&gt;&lt;DIV&gt;The dataset/Datamodel is very simple, We have 3 tables&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Dimension table - Store( Storeid, District,Region)&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Fact Table - Sales (SalesID,Storeid,SalesDate,Amount)&lt;/DIV&gt;&lt;DIV&gt;Calendar( For time Series analysis) -(Date,day,MonthName,Month,Quarter)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Store to Sales - One to many relationship on the basis of Storeid&lt;/DIV&gt;&lt;DIV&gt;Calendar to Sales - One to many relationship on the basis of Date&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This is how my Store table looks like&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;StoreId District Region&lt;/DIV&gt;&lt;DIV&gt;Store1 Mumbai North&lt;/DIV&gt;&lt;DIV&gt;Store2 Nagpur East&lt;/DIV&gt;&lt;DIV&gt;Store3 Kochi North&lt;/DIV&gt;&lt;DIV&gt;Store4 Hyderabad West&lt;/DIV&gt;&lt;DIV&gt;Store5 Delhi North&lt;/DIV&gt;&lt;DIV&gt;Store6 Kanpur East&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This is how my sales data looks like , They have a one to many relationship on the basis of StoreId.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;ID StoreId SalesDate Amount&lt;/DIV&gt;&lt;DIV&gt;1 Store87 15-06-2020 41&lt;/DIV&gt;&lt;DIV&gt;2 Store99 10-07-2021 44&lt;/DIV&gt;&lt;DIV&gt;3 Store70 29-06-2018 39&lt;/DIV&gt;&lt;DIV&gt;4 Store31 05-04-2024 32&lt;/DIV&gt;&lt;DIV&gt;5 Store56 19-01-2023 12&lt;/DIV&gt;&lt;DIV&gt;6 Store25 11-02-2021 79&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Now I want to rank on the basis of District and sales&amp;nbsp; &amp;nbsp;and I am using Region District StoreId in my slicer .&lt;/DIV&gt;&lt;DIV&gt;The output should look like this&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;District|Total Sales|RankBasedonSales&lt;/DIV&gt;&lt;DIV&gt;Delhi|10000|1&lt;/DIV&gt;&lt;DIV&gt;Kanpur|9000|2&lt;/DIV&gt;&lt;DIV&gt;Nagpur|8000|3&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Here Total Sales = SUM(Sales[Amount])&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;when I write the below dax to calculate the rank, It works perfectly if I don't filter anything on my slicer.&lt;/DIV&gt;&lt;DIV&gt;Once I start filtering using slicer the dax breaks&amp;nbsp;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;RankBasedOnSales-Dimension =&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;RANKX(&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; ALLSELECTED(Store[District]),&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; [Total Sales]&lt;/DIV&gt;&lt;DIV&gt;)&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;To Test another approach I added a calculated column in District in my fact table using the related function&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;and I called it calculated District Then I modified the dax as below&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;rankbasedonsales =&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;RANKX(&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;ALLSELECTED(Sales[Calculated District]),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;[Total Sales]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;)&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;after implementing this the dax works perfectly( for this I will use calculated district in my visual along with sales and rank)&lt;/DIV&gt;&lt;DIV&gt;I don't want to add a column for obvious reasons, I am sure we can do it without using the calculated column .&lt;/DIV&gt;&lt;DIV&gt;Can you please help me here&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Jan 2025 16:05:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Not-working-as-expected-when-data-is-filtered-using/m-p/4350645#M172774</guid>
      <dc:creator>Vivek26</dc:creator>
      <dc:date>2025-01-04T16:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx Not working as expected when data is filtered using slicers and filter pane</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Not-working-as-expected-when-data-is-filtered-using/m-p/4350670#M172775</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="435413" data-lia-user-login="Vivek26" class="lia-mention lia-mention-user"&gt;Vivek26&lt;/a&gt;&amp;nbsp;What do you mean by "DAX breaks"? You get an error, you get incorrect results, ... ? You might try RANK instead of RANKX&lt;/P&gt;</description>
      <pubDate>Sat, 04 Jan 2025 17:13:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Not-working-as-expected-when-data-is-filtered-using/m-p/4350670#M172775</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2025-01-04T17:13:34Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx Not working as expected when data is filtered using slicers and filter pane</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Not-working-as-expected-when-data-is-filtered-using/m-p/4350689#M172776</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi Greg , Thanks for replying.&lt;/P&gt;&lt;P&gt;The dax doesn't break but the ranking order gets messed up&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example post filtering , Kanpur may get the 3rd Rank while it should be 2nd&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;District|Total Sales|RankBasedonSales&lt;/DIV&gt;&lt;DIV&gt;Delhi|10000|1&lt;/DIV&gt;&lt;DIV&gt;Kanpur|9000|3&lt;/DIV&gt;&lt;DIV&gt;Nagpur|8000|2&lt;/DIV&gt;</description>
      <pubDate>Sat, 04 Jan 2025 18:11:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Not-working-as-expected-when-data-is-filtered-using/m-p/4350689#M172776</guid>
      <dc:creator>Vivek26</dc:creator>
      <dc:date>2025-01-04T18:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx Not working as expected when data is filtered using slicers and filter pane</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Not-working-as-expected-when-data-is-filtered-using/m-p/4350839#M172780</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="435413" data-lia-user-login="Vivek26" class="lia-mention lia-mention-user"&gt;Vivek26&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;please see below pbix for your reference , the rankx function is showing correct results&lt;/P&gt;&lt;P&gt;you will have to create measure first for sales amount and then use it inside rank function ( do not use sum(col) directly in your rank measure&lt;/P&gt;&lt;P&gt;&lt;A href="https://drive.google.com/file/d/1TmjidSpb2KktCGYUkfRDQlnc_nAWsL3L/view?usp=drive_link" target="_blank" rel="noopener"&gt;https://drive.google.com/file/d/1TmjidSpb2KktCGYUkfRDQlnc_nAWsL3L/view?usp=drive_link&lt;/A&gt;&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;</description>
      <pubDate>Sun, 05 Jan 2025 07:21:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Not-working-as-expected-when-data-is-filtered-using/m-p/4350839#M172780</guid>
      <dc:creator>powerbiexpert22</dc:creator>
      <dc:date>2025-01-05T07:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx Not working as expected when data is filtered using slicers and filter pane</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Not-working-as-expected-when-data-is-filtered-using/m-p/4350849#M172781</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="408509" data-lia-user-login="powerbiexpert22" class="lia-mention lia-mention-user"&gt;powerbiexpert22&lt;/a&gt;&amp;nbsp;. Thanks for replying.&lt;/P&gt;&lt;P&gt;I used your pbix but instead of having 3 different slicers . I used a single one and I started getting the same issue.&lt;/P&gt;&lt;P&gt;My Apoligies I should have clarified my usage of slicer&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;</description>
      <pubDate>Sun, 05 Jan 2025 07:48:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Not-working-as-expected-when-data-is-filtered-using/m-p/4350849#M172781</guid>
      <dc:creator>Vivek26</dc:creator>
      <dc:date>2025-01-05T07:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx Not working as expected when data is filtered using slicers and filter pane</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Not-working-as-expected-when-data-is-filtered-using/m-p/4350878#M172782</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="435413" data-lia-user-login="Vivek26" class="lia-mention lia-mention-user"&gt;Vivek26&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;try to use below&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;rank =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RANKX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ALLSELECTED&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;store&lt;/SPAN&gt;&lt;SPAN&gt;[region]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;store&lt;/SPAN&gt;&lt;SPAN&gt;[district]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;store&lt;/SPAN&gt;&lt;SPAN&gt;[storeid]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;[Total Sales]&lt;/SPAN&gt;&lt;SPAN&gt;,,&lt;/SPAN&gt;&lt;SPAN&gt;DESC&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;Dense&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sun, 05 Jan 2025 09:05:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Not-working-as-expected-when-data-is-filtered-using/m-p/4350878#M172782</guid>
      <dc:creator>powerbiexpert22</dc:creator>
      <dc:date>2025-01-05T09:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx Not working as expected when data is filtered using slicers and filter pane</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Not-working-as-expected-when-data-is-filtered-using/m-p/4351083#M172789</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="408509" data-lia-user-login="powerbiexpert22" class="lia-mention lia-mention-user"&gt;powerbiexpert22&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you filter a specific store in a district, we will again start getting rank 1 for everything . That is my main point of concern.&lt;/P&gt;&lt;P&gt;In a district we want to exclude certain stores .&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jan 2025 21:01:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Not-working-as-expected-when-data-is-filtered-using/m-p/4351083#M172789</guid>
      <dc:creator>Vivek26</dc:creator>
      <dc:date>2025-01-05T21:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx Not working as expected when data is filtered using slicers and filter pane</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Not-working-as-expected-when-data-is-filtered-using/m-p/4351134#M172792</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="435413" data-lia-user-login="Vivek26" class="lia-mention lia-mention-user"&gt;Vivek26&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;can you let me know in which scenario in my pbix file is giving all ones?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2025 00:30:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Not-working-as-expected-when-data-is-filtered-using/m-p/4351134#M172792</guid>
      <dc:creator>powerbiexpert22</dc:creator>
      <dc:date>2025-01-06T00:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx Not working as expected when data is filtered using slicers and filter pane</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Not-working-as-expected-when-data-is-filtered-using/m-p/4351609#M172806</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="435413" data-lia-user-login="Vivek26" class="lia-mention lia-mention-user"&gt;Vivek26&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please check this measure.&amp;nbsp;Although it is not concise enough, it seems to meet your requirements.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;rank = 
var currentDistrict = SELECTEDVALUE(Store[District])
var sumTable = SUMMARIZE(ALLSELECTED(Store),Store[Region],Store[District],"Total_Amount",[Total Sales])
var rankTable = ADDCOLUMNS(sumTable,"Rank_Value",RANK(DENSE,sumTable,ORDERBY([Total_Amount],DESC)))
return
MAXX(FILTER(rankTable,[District] = currentDistrict),[Rank_Value])&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;I struggled a lot but haven't figured out a method with RANKX yet. Hope this would be helpful.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Jing&lt;BR /&gt;&lt;EM&gt;If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos! &lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2025 08:44:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Not-working-as-expected-when-data-is-filtered-using/m-p/4351609#M172806</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-01-06T08:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx Not working as expected when data is filtered using slicers and filter pane</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Not-working-as-expected-when-data-is-filtered-using/m-p/4352294#M172831</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;. Thanks a lot for the reply. The solution worked.&lt;/P&gt;&lt;P&gt;Please do let me know if you are able to solve it with Rankx as well.&lt;/P&gt;&lt;P&gt;I also Invested a lot of time with Rankx but I was not able to find a good solution.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2025 18:48:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-Not-working-as-expected-when-data-is-filtered-using/m-p/4352294#M172831</guid>
      <dc:creator>Vivek26</dc:creator>
      <dc:date>2025-01-06T18:48:33Z</dc:date>
    </item>
  </channel>
</rss>

