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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
harib
Post Patron
Post Patron

Rank function not giving distinct values when same value exists

Hi Everyone,

 

Can anyone let me know how to get distinct values when same values exists in the table. In the below table i have used Rank function , but not getting distinct values for the same values, due to that i'm not getting 100% in the percent column. 😞 

 

Rank = RANKX(ALLSELECTED('Table'[Field]), [Record Counter])

4.PNG

 

Thanks in advacne 

1 ACCEPTED SOLUTION
v-lid-msft
Community Support
Community Support

Hi @harib ,

 

We can try to use the following measure to meet your requirement:

 

Rank = 
IF (
    ISINSCOPE ( 'Table'[Field] ),
    RANKX (
        ALLSELECTED ( 'Table'[Field] ),
        RANKX ( ALLSELECTED ( 'Table'[Field] ), [Record Counter],, ASC, DENSE )
            + RANKX (
                ALLSELECTED ( 'Table'[Field] ),
                CALCULATE ( MAX ( [Field] ) ),
                ,
                DESC,
                DENSE
            )
                / CALCULATE ( DISTINCTCOUNT ( 'Table'[Field] ), ALLSELECTED ( 'Table'[Field] ) ),
        ,
        DESC,
        DENSE
    )
)

 

4.jpg

 

If it doesn't meet your requirement, Could you please show the exact expected result based on the Tables that you have shared?

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-lid-msft
Community Support
Community Support

Hi @harib ,

 

We can try to use the following measure to meet your requirement:

 

Rank = 
IF (
    ISINSCOPE ( 'Table'[Field] ),
    RANKX (
        ALLSELECTED ( 'Table'[Field] ),
        RANKX ( ALLSELECTED ( 'Table'[Field] ), [Record Counter],, ASC, DENSE )
            + RANKX (
                ALLSELECTED ( 'Table'[Field] ),
                CALCULATE ( MAX ( [Field] ) ),
                ,
                DESC,
                DENSE
            )
                / CALCULATE ( DISTINCTCOUNT ( 'Table'[Field] ), ALLSELECTED ( 'Table'[Field] ) ),
        ,
        DESC,
        DENSE
    )
)

 

4.jpg

 

If it doesn't meet your requirement, Could you please show the exact expected result based on the Tables that you have shared?

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

Refer : How to break ties in

https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Connect on Linkedin

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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