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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
renecornish
Regular Visitor

Ranking Across Columns

I have distance travelled data between various locations ~ stipulated in individual columns.  I am now wanting to rank which location is first, second, third closest (or less in distance).  How do I rank theses?  I can't seem to Group the columns as I was hoping to use the RANK.EQ formaul which works in excel and not here.

 

Example:  Location 1 is positioned 3rd closest...

renecornish_0-1722604271364.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thank you for your prompt reply @Greg_Deckler 

Hi @renecornish
 

 

Based on your needs, I have created the following table.

vjialongymsft_0-1722822421633.png

 

Then in power query, hold down the Ctrl key to select all columns, click "unpivot column".

vjialongymsft_1-1722822611924.png


Click"close and apply", Then you can use the following Dax to get the rank of the column:

Column = RANKX('Table','Table'[Value],,DESC)

 

Result:

vjialongymsft_2-1722822988528.png



Best Regards,

Jayleny

 

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

Thank you for your prompt reply @Greg_Deckler 

Hi @renecornish
 

 

Based on your needs, I have created the following table.

vjialongymsft_0-1722822421633.png

 

Then in power query, hold down the Ctrl key to select all columns, click "unpivot column".

vjialongymsft_1-1722822611924.png


Click"close and apply", Then you can use the following Dax to get the rank of the column:

Column = RANKX('Table','Table'[Value],,DESC)

 

Result:

vjialongymsft_2-1722822988528.png



Best Regards,

Jayleny

 

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

renecornish
Regular Visitor

Thank you Greg, however when I use this (as above) - it runs an error.  "A table of multiple values was supplied where a single value was expected".

Greg_Deckler
Community Champion
Community Champion

@renecornish Probably have to do something along these lines:

Column = 
  VAR __Table = 
    UNION(
      { [Location 1] },
      { [Location 2] },
      { [Location 3] },
      { [Location 4] },
      { [Location 5] },
      { [Location 6] }
    )
...

      

Then you could use RANKX and then lookup the RANK for whatever value [Location 1] is for your Location 1 rank column, etc.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
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.