Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
tkiwi
Frequent Visitor

RANK not working with specific columns

Hey everyone, I wanted to share an issue I encountered while working with the DAX RANK function in Power BI.

I noticed that this function works with some columns from my dimension, but not with others in the same dimension.

 

So here is my working code

__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
            )
        )
    )

So my ranking works as expected

tkiwi_0-1719392663921.png

 

But now, if I want to use another column from the same dimension in the matrix and change also my code to

__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
            )
        )
    )

I get the following result:

tkiwi_1-1719392723642.png

 

As you can see, I only changed the column in my ALLSELECTED()-Part and in the RANK-Part.

 

Has anyone else experienced this issue or is there something wrong in my code?

 

Looking forward to hearing your thoughts and suggestions. Thanks!

1 REPLY 1
v-jiewu-msft
Community Support
Community Support

Hi @tkiwi ,

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.

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.

vjiewumsft_0-1719470139629.png

Then, try to verify the data type of the column and check the values.

Besides, ALLSELECTED function gets the context that represents all rows and columns in the query.

 

Viewing the following documents to learn more information.

RANK function (DAX) - DAX | Microsoft Learn

ALLSELECTED function (DAX) - DAX | Microsoft Learn

Solved: Rankx not displaying ranking properly - Microsoft Fabric Community

 

Best Regards,

Wisdom Wu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.