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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Ranking a column in a table

Forgive me 😊Im a little new to DAX ---

Below I show my table PBI_ae272LeadsReport

How do I  create a MEASURE  that will rank the CLIENT # column  in descending order ....based on values in the 'LFT_Purchase' column?

Ive tried writing the DAX but Im doing something wrong ---need your help please

 

 

LeadsReportTable Oct 15 2020LeadsReportTable Oct 15 2020

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

Hi, @Anonymous 

You don’t have to use a measure to rank the value of [LFT Purchase], you can just do it in power query editor, you can follow my steps:

  1. Open power query editor, select the table, select the column you want to rank, and choose sort descending, like this:

v-robertq-msft_0-1602831291578.png

 

  1. Add an index column, like this:

v-robertq-msft_1-1602831291582.png

 

  1. Rename this column, and put them into a table chart, like this:

屏幕截图 2020-10-16 145626.png

 

If you still want to achieve this in DAX, you can try this calculated column:

Rank = RANKX(PBI,MAX('PBI'[LFT Purchase]),,DESC)

 

If you this way is not suitable for your requirement, you can reply to me and post some sample data(without sensitive data) and your expected result.

Here are some good blog that tell how to sort columns using dax, you can follow these links to learn more about sorting in power bi:

https://www.wiseowl.co.uk/blog/s2469/rankx-function.htm

https://powerbi.tips/2019/09/custom-sort-order-within-a-dax-measure/

 

Best Regards,

Community Support Team _Robert Qin

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-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

You don’t have to use a measure to rank the value of [LFT Purchase], you can just do it in power query editor, you can follow my steps:

  1. Open power query editor, select the table, select the column you want to rank, and choose sort descending, like this:

v-robertq-msft_0-1602831291578.png

 

  1. Add an index column, like this:

v-robertq-msft_1-1602831291582.png

 

  1. Rename this column, and put them into a table chart, like this:

屏幕截图 2020-10-16 145626.png

 

If you still want to achieve this in DAX, you can try this calculated column:

Rank = RANKX(PBI,MAX('PBI'[LFT Purchase]),,DESC)

 

If you this way is not suitable for your requirement, you can reply to me and post some sample data(without sensitive data) and your expected result.

Here are some good blog that tell how to sort columns using dax, you can follow these links to learn more about sorting in power bi:

https://www.wiseowl.co.uk/blog/s2469/rankx-function.htm

https://powerbi.tips/2019/09/custom-sort-order-within-a-dax-measure/

 

Best Regards,

Community Support Team _Robert Qin

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

@Anonymous , You can have column/static rank

rankx(All(Table[client#]), [LFT_Purchase],,desc, dense)

 

measure rank


rankx(All(Table[client#]), calculate(sum(Table[LFT_Purchase])),,desc, dense)

or


rankx(Allselected(Table[client#]), calculate(sum(Table[LFT_Purchase])),,desc, dense)

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/367415

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.