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

Get Fabric Certified for FREE during AI Skills Fest. This week only. Secure your voucher now.

Reply
joshua1990
Post Prodigy
Post Prodigy

Rank based on two columns

Hi experts!

I know, there have been a lot of posts regarding this, but they have not been useful for me.

The objective is to have a ranking based on two columns.

 

I have a dimension table (Table Dim) that lists all of our products.

Then I have a table (Table Trans) that some transactional values in different columns.

There is the first column called Column1 and another one called Column2.

Now I would like to build a ranking for each product based on Column2 as the first priority and Column1 as the second priority.

Using this DAX Measure I get the ranking for each column:

 

 

Rank1 =
    RANKX ( ALLSELECTED ( 'Table Dim'[Product] ), [Column1] )

 

 

 

 

Rank2 =
    RANKX ( ALLSELECTED ( 'Table Dim'[Product] ), [Column2] )

 

 

 

 

As a result, now I have the following:

ProductRank1Rank2Rank Total
A1104
A5222
A3311
A4433
A250

5

 

The Rank Total column shows the result that I need.

 

How is this possible using DAX?

6 REPLIES 6
Anonymous
Not applicable

Hi @joshua1990 ,

 

Are your Rank1 and Rank2 calculated columns or measures? There are differences between the two, please refer to

Calculated Columns and Measures in DAX - SQLBI.

 

Please provide some sample data, which will help me create the correct formula.

 

For now, you can refer to this post to try to solve it.

 

 

Best Regards,

Stephen Tao

 

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

 

AlexisOlson
Super User
Super User

smpa01
Community Champion
Community Champion

@joshua1990  the logic for RankTotal is not clear. Please bare more details as to how you arrived there?


========================
Did I answer your question? Mark my post as a solution!
Proud to be a Super User
My Custom Visualization Projects
• Plotting Live Sound: Live Sound
• Beautiful News: Women in Parliament, Energy Mix, Shrinking Armies
• Visual Capitalist: Working Hrs
• Others: Easing Graph, Animated Calendar
MayViz Submissions
• Week 1: View
• Week 2: View
• Week 3: View
• Week 4: View
========================

@smpa01: Thanks for your reply.

First, the Rank Total is based on the numerical value in Rank2. Then all remaining products are based on Rank1.

@joshua1990  do I understand that if Rank2 =1 then that Product is Ranked 1 in Rank Total and rest of the products need to be Ranked again as per Rank1?


========================
Did I answer your question? Mark my post as a solution!
Proud to be a Super User
My Custom Visualization Projects
• Plotting Live Sound: Live Sound
• Beautiful News: Women in Parliament, Energy Mix, Shrinking Armies
• Visual Capitalist: Working Hrs
• Others: Easing Graph, Animated Calendar
MayViz Submissions
• Week 1: View
• Week 2: View
• Week 3: View
• Week 4: View
========================
amitchandak
Super User
Super User

@joshua1990 , Need some data to suggest for column1 and column 2. If they are numbers 

 

Rank1 =
    RANKX ( ALLSELECTED ( 'Table Dim'[Product] ), [Column1]+ [Column2] )


Rank1 =
    RANKX ( ALLSELECTED ( 'Table Dim'[Product] ),calculate( [Column1]+ [Column2] ) ) 
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.