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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
vibhoryadav23
Helper II
Helper II

Ranking on multiple columns

Hi all,

 

I want to create ranking in the data table (not in a visual) based on 2 categories (Column1,2) instead of 1 like in example below. Can someone help with the ranking formula to create a new ranking column instead of creating a new measure. Thanks in advance!

Column1  Sales  Rank
A  10  2
A  5  3
A  15  1
B  20  2
B  30  1
B  10  3
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @vibhoryadav23 ,

 

1. If your third column is the result you expect, you can create a calculated column and use the rankx function to sort. For detailed information, please refer to the document: RANKX function (DAX) - DAX | Microsoft Learn.

Ranking =
RANKX(
FILTER(
'Table',
'Table'[Column1] = EARLIER('Table'[Column1])
),
'Table'[Sales],
,
DESC,
Dense
)

2. If you want to sort the data in the second column according to size, you can place the fields in the table visual and adjust the sorting through the small triangle under the column name.

vkaiyuemsft_0-1709108728635.png

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

3 REPLIES 3
Anonymous
Not applicable

Hi @vibhoryadav23 ,

 

1. If your third column is the result you expect, you can create a calculated column and use the rankx function to sort. For detailed information, please refer to the document: RANKX function (DAX) - DAX | Microsoft Learn.

Ranking =
RANKX(
FILTER(
'Table',
'Table'[Column1] = EARLIER('Table'[Column1])
),
'Table'[Sales],
,
DESC,
Dense
)

2. If you want to sort the data in the second column according to size, you can place the fields in the table visual and adjust the sorting through the small triangle under the column name.

vkaiyuemsft_0-1709108728635.png

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

Syk
Super User
Super User

How are you wanting the ranking to work? 
A, Product 1 = 1
A, Product 2 = 2
B, Product 1 = 3

B, Product 2 = 4

?

Sorry, the table posted was the wrong one. Updated the same. Column3, 'Rank' is the expected outcome based on first 2 columns. Thanks.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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