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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Soof1234
Helper I
Helper I

Make continuous ranking if values are the same

Hi, 

Well known issue, but the related posts mostly contain solutions based on a column by adding an index. My problem however, is that I created the ranking based on a measure. 

 

I created a rankingmeasure based on a count measure, see below: 

 

Intakes = COUNT(Intakes[Id])

 

Ranking =
RANKX( ALL(Intakes[Sourcers.Title]),[Intakes])
 
Column name in tablevisual below is from a column in a table
Intakes[Sourcers.Title]:
 
In below table I want to see the rank like 5,6,7,8 instead of 5,5,5,8. Even if the amount of intakes is the same.
 
Soof1234_1-1674141358997.png

 

Any suggestions on how to solve this. Tried to check related topics but these mostly contains rankings based on columns instead of measures. Thanks in advance!

 

Kind Regards,

 

Soof1234

 

1 ACCEPTED SOLUTION

Hi,

Thank you for your message, and please check the below picture and the attached pbix file.

Jihwan_Kim_0-1674202255303.png

 

Rank: =
VAR _table =
    ADDCOLUMNS (
        ADDCOLUMNS (
            ALL ( Intakes[Sourcers.Title] ),
            "@rankone", CALCULATE ( RANKX ( ALL ( Intakes[Sourcers.Title] ), [Intakes:],, DESC ) ),
            "@ranktwo",
                CALCULATE (
                    RANKX (
                        ALL ( Intakes[Sourcers.Title] ),
                        CALCULATE ( MAX ( Intakes[Sourcers.Title] ) ),
                        ,
                        ASC
                    )
                )
        ),
        "@newindex",
            [@rankone] * 100 + [@ranktwo]
    )
VAR _newtable =
    ADDCOLUMNS ( _table, "@newrank", RANKX ( _table, [@newindex],, ASC ) )
RETURN
    IF (
        HASONEVALUE ( Intakes[Sourcers.Title] ),
        MAXX (
            FILTER ( _newtable, Intakes[Sourcers.Title] = MAX ( Intakes[Sourcers.Title] ) ),
            [@newrank]
        )
    )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

10 REPLIES 10
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your data model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

I hope the below can provide some ideas on how to create a solution for your data model.

 

Jihwan_Kim_0-1674141990257.png

 

Rank expected result: =
COUNTROWS (
    WINDOW (
        1,
        ABS,
        0,
        REL,
        SUMMARIZE ( ALL ( Data ), Data[Name], Data[Qty] ),
        ORDERBY ( Data[Qty], DESC, Data[Name], ASC )
    )
)

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Greate Job Jihwan_Kim,
It worked for me, really appreciate your work.

 

Hi @Jihwan_Kim ,

 

Didnt work unfortunately. I cant upload a file here because of user level probably.

 

My table looks like this

 

Sourcers.Title
Kevin
Jane
Kevin
Jane
Rob
Joy
Joy
Kevin
Jane

 

Intakes = COUNT(Intakes[Sourcers.Title])
Ranking = RANKX( ALL(Intakes[Sourcers.Title]),[Intakes])

Based on these measures, the tablevisual would look like this:
 
RankSourcers.TitleIntakes
1Kevin3
1Jane3
3Joy2
4Rob1


 
What i want to achieve is that either jane or kevin gets ranking 2, this could be based on alphabetical order for example. Hope this is clear enough for you.
 
Kind Regards,
 
Soof1234

Hi,

Thank you for your message, and please check the below picture and the attached pbix file.

Jihwan_Kim_0-1674202255303.png

 

Rank: =
VAR _table =
    ADDCOLUMNS (
        ADDCOLUMNS (
            ALL ( Intakes[Sourcers.Title] ),
            "@rankone", CALCULATE ( RANKX ( ALL ( Intakes[Sourcers.Title] ), [Intakes:],, DESC ) ),
            "@ranktwo",
                CALCULATE (
                    RANKX (
                        ALL ( Intakes[Sourcers.Title] ),
                        CALCULATE ( MAX ( Intakes[Sourcers.Title] ) ),
                        ,
                        ASC
                    )
                )
        ),
        "@newindex",
            [@rankone] * 100 + [@ranktwo]
    )
VAR _newtable =
    ADDCOLUMNS ( _table, "@newrank", RANKX ( _table, [@newindex],, ASC ) )
RETURN
    IF (
        HASONEVALUE ( Intakes[Sourcers.Title] ),
        MAXX (
            FILTER ( _newtable, Intakes[Sourcers.Title] = MAX ( Intakes[Sourcers.Title] ) ),
            [@newrank]
        )
    )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Hi @Jihwan_Kim ,

 

Hope you are able to resolve this one as well. I added an image from an URL to a separate table with all names of the employees and converted that to type imageURL. It displays the correct image to the belonging person, however it breaks the ranking. I tried to add the image as @columnthree in your measure, but it doesnt work properly.

 

My data still looks like this

 

Sourcers.Title
Kevin
Jane
Kevin
Jane
Rob
Joy
Joy
Kevin
Jane

 

Intakes = COUNT(Intakes[Sourcers.Title])
Ranking = RANKXALL(Intakes[Sourcers.Title]),[Intakes])

Based on these measures, the tablevisual would look like this:
 
RankSourcers.TitleIntakes
1Kevin3
1Jane3
3Joy2
4Rob1

 

I have a separate table with a relationship 1:* with Sourcers.title -> Medewerkers.Title

 

Medewerkers.TitleImageURL
Janewww.jane.com/test
Robwww.rob.com/test
Joywww.joy.com/testtest

 

You can see that the ranking is 1 for everyone below but it should be the same as in your previous solution. Tried to add a @columnthree to the measure you gave me, but couldnt get it correct.

 

Soof1234_0-1674284198050.png

 

Hope you got the solution for this as well, as it would finalize my report. Thanks in advance!

 

Kind Regards, 

Soof1234

Hi,

Please share your sample pbix file's link, and then I can try to look into it to come up with a solution.

If you add a column to the table, in most cases, datamodel is considered as different. Which means, in some cases, measures has to be fixed to show expected results.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Hi,

 

Thanks for the help. I cannot upload a file here, but uploaded it on a filesharing website. I used dummy data but with exactly the same column names. I added a third ADDCOLUMN in the measure you supplied but couldnt retrieve the correct rank.

 

This is the part I added:

 

  ,"@rankthree",
                CALCULATE (
                    RANKX (
                        ALL ( Medewerkers[ProfilePic.Url]),
                        CALCULATE ( MAX ( Medewerkers[ProfilePic.Url] ) ),
                        ,
                        ASC))),

The link to the dummy file:
 
 
Thanks in advance!
 
Kind Regards, Soof1234

Hi,

I cannot open the file in the link. 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Hi, 

 

Excuse me, WEtransfer should do the job. 

 

https://we.tl/t-Ulz9aUZdzt

 

Kind Regards,

 

Soof1234

Thanks a lot! This works perfectly, also tested it with a lot of equal intakes! See below:

 

Soof1234_0-1674207202107.png

 

Kind Regards,

 

Soof1234

 

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!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.