Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

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 'LF...
  • v-robertq-msft's avatar
    5 years ago

    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:

     

    1. Add an index column, like this:

     

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

     

    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.