cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ashisha11
Frequent Visitor

Getting Rank of Text Column which has duplicate records

I am not sure how to mention this. I have a simple table as below. I am trying to get the rank basis on 'Name' Column which has duplicate record. Can any one help whether this can be achieved in power bi? Thanks in Advance.

NameDesired Output (Rank)
A1
A2
A3
A4
B1
B2
B3
C1
C2
C3
C4
C5
C6

 

2 ACCEPTED SOLUTIONS

Hi @ashisha11 

 

Once you've added your index column, you can use the DAX expression below to create your rank column:

Rank = 
VAR RowName = Table1[Name]
VAR Result = 
RANKX(
    FILTER(
        ALL( Table1 ),
        Table1[Name] = RowName
    ),
    Table1[Index],
    ,ASC
)
RETURN Result

 

Best regards,
Martyn

View solution in original post

Anonymous
Not applicable

Create one index column and then create one more column as below.

 

Rank = CALCULATE(COUNT('Table'[Col]),FILTER('Table','Table'[Col]=EARLIER('Table'[Col]) && 'Table'[Index]<=EARLIER('Table'[Index])))
 
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

View solution in original post

7 REPLIES 7
Tani4ka
Helper I
Helper I

I have a similar problem with ranking. What I need is to have all channel_grouping_1 have the same rank. Offline Only 1 across all lines, Direct 2 across all lines etc. Can anyone help? 

Tani4ka_0-1625044624068.png

Many thanks

az38
Community Champion
Community Champion

Hi @ashisha11 

the easiest way is to add a Custom Index Column in Power Query Editor mode

then try to create a calculated DAX column like

RANK = 
var _RowsBefore = COUNTROWS(FILTER('Table', 'Table'[Name]<EARLIER('Table'[Name])))
RETURN
rankx(FILTER('Table', 'Table'[Name]=EARLIER('Table'[Name])), 'Table'[Index],,ASC) + _RowsBefore

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Hi  

 

 

Hi @ashisha11 

 

Once you've added your index column, you can use the DAX expression below to create your rank column:

Rank = 
VAR RowName = Table1[Name]
VAR Result = 
RANKX(
    FILTER(
        ALL( Table1 ),
        Table1[Name] = RowName
    ),
    Table1[Index],
    ,ASC
)
RETURN Result

 

Best regards,
Martyn

Hi @MartynRamsden 

Perfect! This answers my query. Thanks a lot for your help.

 

Regards!

Anonymous
Not applicable

Create one index column and then create one more column as below.

 

Rank = CALCULATE(COUNT('Table'[Col]),FILTER('Table','Table'[Col]=EARLIER('Table'[Col]) && 'Table'[Index]<=EARLIER('Table'[Index])))
 
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

Hi @Anonymous 

 

Perfect, This is also a solution to my concern. Thanks a lot for your help.

 

Regards,

 

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Top Solution Authors
Top Kudoed Authors