<?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 RANK not working with specific columns in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANK-not-working-with-specific-columns/m-p/4010878#M157851</link>
    <description>&lt;P&gt;Hey everyone, I wanted to share an issue I encountered while working with the DAX RANK function in Power BI.&lt;/P&gt;&lt;P&gt;I noticed that this function works with some columns from my dimension, but not with others in the same dimension.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So here is my working code&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;__Rank =
var _relevantProducts =
    ADDCOLUMNS
    (
        ALLSELECTED ( Produkte[StabileArtikelNr mit Nummer] )
        , "@Umsatz", [Umsatz]
    )
 
RETURN
IF (NOT ISBLANK([Umsatz] )
    ,
        RANK
        (
            DENSE
            , _relevantProducts
            , ORDERBY
            (
                [@Umsatz]
                , DESC
                , Produkte[StabileArtikelNr mit Nummer]
                , ASC
            )
        )
    )&lt;/LI-CODE&gt;&lt;P&gt;So my ranking works as expected&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But now, if I want to use another column from the same dimension in the matrix and change also my code to&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;__Rank =
var _relevantProducts =
    ADDCOLUMNS
    (
        ALLSELECTED ( Produkte[Stabile ArtikelNr Bezeichnung] )
        , "@Umsatz", [Umsatz]
    )
 
RETURN
IF (NOT ISBLANK([Umsatz] )
    ,
        RANK
        (
            DENSE
            , _relevantProducts
            , ORDERBY
            (
                [@Umsatz]
                , DESC
                , Produkte[Stabile ArtikelNr Bezeichnung]
                , ASC
            )
        )
    )&lt;/LI-CODE&gt;&lt;P&gt;I get the following result:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see, I only changed the column in my ALLSELECTED()-Part and in the RANK-Part.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anyone else experienced this issue or is there something wrong in my code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking forward to hearing your thoughts and suggestions. Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jun 2024 09:07:59 GMT</pubDate>
    <dc:creator>tkiwi</dc:creator>
    <dc:date>2024-06-26T09:07:59Z</dc:date>
    <item>
      <title>RANK not working with specific columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANK-not-working-with-specific-columns/m-p/4010878#M157851</link>
      <description>&lt;P&gt;Hey everyone, I wanted to share an issue I encountered while working with the DAX RANK function in Power BI.&lt;/P&gt;&lt;P&gt;I noticed that this function works with some columns from my dimension, but not with others in the same dimension.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So here is my working code&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;__Rank =
var _relevantProducts =
    ADDCOLUMNS
    (
        ALLSELECTED ( Produkte[StabileArtikelNr mit Nummer] )
        , "@Umsatz", [Umsatz]
    )
 
RETURN
IF (NOT ISBLANK([Umsatz] )
    ,
        RANK
        (
            DENSE
            , _relevantProducts
            , ORDERBY
            (
                [@Umsatz]
                , DESC
                , Produkte[StabileArtikelNr mit Nummer]
                , ASC
            )
        )
    )&lt;/LI-CODE&gt;&lt;P&gt;So my ranking works as expected&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But now, if I want to use another column from the same dimension in the matrix and change also my code to&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;__Rank =
var _relevantProducts =
    ADDCOLUMNS
    (
        ALLSELECTED ( Produkte[Stabile ArtikelNr Bezeichnung] )
        , "@Umsatz", [Umsatz]
    )
 
RETURN
IF (NOT ISBLANK([Umsatz] )
    ,
        RANK
        (
            DENSE
            , _relevantProducts
            , ORDERBY
            (
                [@Umsatz]
                , DESC
                , Produkte[Stabile ArtikelNr Bezeichnung]
                , ASC
            )
        )
    )&lt;/LI-CODE&gt;&lt;P&gt;I get the following result:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see, I only changed the column in my ALLSELECTED()-Part and in the RANK-Part.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anyone else experienced this issue or is there something wrong in my code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking forward to hearing your thoughts and suggestions. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2024 09:07:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANK-not-working-with-specific-columns/m-p/4010878#M157851</guid>
      <dc:creator>tkiwi</dc:creator>
      <dc:date>2024-06-26T09:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: RANK not working with specific columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANK-not-working-with-specific-columns/m-p/4012728#M158025</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="328095" data-lia-user-login="tkiwi" class="lia-mention lia-mention-user"&gt;tkiwi&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Based on the description, for the Stabile ArtikelNr Bezeichnung column , the rows have the same ranking. It is normal for the row to have the same ranking when using rank dax.&lt;/P&gt;
&lt;P&gt;Rank function have some limitations. If the columns specified within orderby and partitonby cannot uniquely identify every row in relation, then two or more rows may have same ranking.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Then, try to verify the data type of the column and check the values.&lt;/P&gt;
&lt;P&gt;Besides, ALLSELECTED function gets the context that represents all rows and columns in the query.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Viewing the following documents to learn more information.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/rank-function-dax" target="_blank" rel="noopener"&gt;RANK function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/allselected-function-dax" target="_blank" rel="noopener"&gt;ALLSELECTED function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.fabric.microsoft.com/t5/Desktop/Rankx-not-displaying-ranking-properly/td-p/1001280" target="_blank"&gt;Solved: Rankx not displaying ranking properly - Microsoft Fabric Community&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Wisdom Wu&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2024 06:40:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/RANK-not-working-with-specific-columns/m-p/4012728#M158025</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-06-27T06:40:43Z</dc:date>
    </item>
  </channel>
</rss>

