<?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 Rankx calculated column unexpected ranking discrepancies in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-calculated-column-unexpected-ranking-discrepancies/m-p/4024966#M158898</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a perfectly working measure to give each 'Location' a different value. None of these values are unique, to prevent multiple locations ranked on the same position (because for example X = 2nd&amp;nbsp; and Y = 2nd would be a problem for visuals).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on this 'Location value', I've added a calculated column (for use in filters/slicers) to rank the locations with RANKX.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The ranking only applies to a selected 'Species group'. So for birds X = 1 and Y = 2, but for mammals Y = 1 and Z = 2, for example.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For 307 locations, this works just fine. But weirdly enough it goes wrong for 3 locations (marked in yellow), which have very low location values (also marked yellow), but are somehow matched equally to positions 1, 3 and 4. This makes no sense to me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I doing wrong?&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;LI-CODE lang="markup"&gt;location rank srtgrp = 
VAR SelectedUser = Data[user]

VAR SelectedSpeciesGroup = Data[species group]

VAR TabelUser = 
    FILTER ( Data ; 
    Data[user] = SelectedUser )

RETURN
RANKX (  
    TabelUser  ; 
    CALCULATE ( 
        [Location value] ; 
        ALLEXCEPT( Data ; Data[location] ) ; 
        Data[species group] = SelectedSpeciesGroup 
    ) ;; DESC ; Dense
)&lt;/LI-CODE&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;&lt;img /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jul 2024 10:57:45 GMT</pubDate>
    <dc:creator>Joris_NL</dc:creator>
    <dc:date>2024-07-04T10:57:45Z</dc:date>
    <item>
      <title>Rankx calculated column unexpected ranking discrepancies</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-calculated-column-unexpected-ranking-discrepancies/m-p/4024966#M158898</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a perfectly working measure to give each 'Location' a different value. None of these values are unique, to prevent multiple locations ranked on the same position (because for example X = 2nd&amp;nbsp; and Y = 2nd would be a problem for visuals).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on this 'Location value', I've added a calculated column (for use in filters/slicers) to rank the locations with RANKX.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The ranking only applies to a selected 'Species group'. So for birds X = 1 and Y = 2, but for mammals Y = 1 and Z = 2, for example.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For 307 locations, this works just fine. But weirdly enough it goes wrong for 3 locations (marked in yellow), which have very low location values (also marked yellow), but are somehow matched equally to positions 1, 3 and 4. This makes no sense to me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I doing wrong?&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;LI-CODE lang="markup"&gt;location rank srtgrp = 
VAR SelectedUser = Data[user]

VAR SelectedSpeciesGroup = Data[species group]

VAR TabelUser = 
    FILTER ( Data ; 
    Data[user] = SelectedUser )

RETURN
RANKX (  
    TabelUser  ; 
    CALCULATE ( 
        [Location value] ; 
        ALLEXCEPT( Data ; Data[location] ) ; 
        Data[species group] = SelectedSpeciesGroup 
    ) ;; DESC ; Dense
)&lt;/LI-CODE&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;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jul 2024 10:57:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-calculated-column-unexpected-ranking-discrepancies/m-p/4024966#M158898</guid>
      <dc:creator>Joris_NL</dc:creator>
      <dc:date>2024-07-04T10:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx calculated column unexpected ranking discrepancies</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-calculated-column-unexpected-ranking-discrepancies/m-p/4025833#M158944</link>
      <description>&lt;LI-CODE lang="markup"&gt;What am I doing wrong?&lt;/LI-CODE&gt;
&lt;P&gt;You created a calculated column from a measure. That is unfortunately technically possible but it makes no business sense, as you are missing the filter context.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2024 00:43:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-calculated-column-unexpected-ranking-discrepancies/m-p/4025833#M158944</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-07-05T00:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx calculated column unexpected ranking discrepancies</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-calculated-column-unexpected-ranking-discrepancies/m-p/4026447#M158995</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="395733" data-lia-user-login="Joris_NL" class="lia-mention lia-mention-user"&gt;Joris_NL&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can give you the idea of converting it to a measure, realized through a virtual table, as you can see in the following results:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = var _t = ADDCOLUMNS('Table',"Rank",RANKX(FILTER(ALL('Table'),[ColumnX]=EARLIER([ColumnX])),[Value],,DESC,Dense))
RETURN MAXX(_t,[Rank])&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;An attachment for your reference. Hope it helps!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;BR /&gt;Community Support Team_ Scott Chang&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this post helps then please consider&amp;nbsp;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2024 06:51:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-calculated-column-unexpected-ranking-discrepancies/m-p/4026447#M158995</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-07-05T06:51:41Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx calculated column unexpected ranking discrepancies</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-calculated-column-unexpected-ranking-discrepancies/m-p/4030317#M159351</link>
      <description>&lt;P&gt;Thanks for the tip, but people doing this wrong would need a bit more explanation than this. If I understand correctly, solve it either by ranking with (calculated) columns only, or by measures only. But not with measures inside calculated columns. Right?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;In my case, that would either require very elaborate calculated columns with lots of variables or lots of columns. Or I could solve it by using measures only, not allowing me to filter or slice on visuals for let's say 'location ranked 3rd' only.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2024 13:18:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-calculated-column-unexpected-ranking-discrepancies/m-p/4030317#M159351</guid>
      <dc:creator>Joris_NL</dc:creator>
      <dc:date>2024-07-08T13:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx calculated column unexpected ranking discrepancies</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-calculated-column-unexpected-ranking-discrepancies/m-p/4030369#M159354</link>
      <description>&lt;P&gt;Thank you. The example file worked, but integrating the measure into my file (with more than&amp;nbsp;those columns to filter on) went wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was actually hoping for a column as a solution, so I would be able to use it as a slicer/filter. So I delved deeper and (finally!) found a rare occurance of two different products (animal species in my case) with the same name.&amp;nbsp; Ranking 310 locations gave only 3 discrepancies which hadn't been noticed in other measures. So nothing wrong with the DAX I posted here - and yours probably work fine as well. Again, thank you for the effort! I'll use your RANKX measure next time.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2024 13:29:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-calculated-column-unexpected-ranking-discrepancies/m-p/4030369#M159354</guid>
      <dc:creator>Joris_NL</dc:creator>
      <dc:date>2024-07-08T13:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: Rankx calculated column unexpected ranking discrepancies</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-calculated-column-unexpected-ranking-discrepancies/m-p/4030513#M159363</link>
      <description>&lt;P&gt;Here's a great article:&amp;nbsp;&lt;A href="https://www.sqlbi.com/articles/use-of-rankx-in-power-bi-measures/" target="_blank"&gt;https://www.sqlbi.com/articles/use-of-rankx-in-power-bi-measures/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2024 14:18:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Rankx-calculated-column-unexpected-ranking-discrepancies/m-p/4030513#M159363</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-07-08T14:18:36Z</dc:date>
    </item>
  </channel>
</rss>

