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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.