cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
sliu7 Frequent Visitor
Frequent Visitor

RANKX problem

I have a very simple table to test out the RANKX function shown below

 

countriesvalue
Japan3456234
china23452345
france6543
usa12346
sinagpore54322

 

i'm trying to create a new column called rank, and in the column header i used the RANKX code as follow:

 

Rank = RANKX (ALL(Sheet1[countries]),Sheet1[value])
 
But the rank column returns 1 for every value. However ,when i use 
 
Rank = RANKX (ALL(Sheet1),Sheet1[value])
 
the rank column works as intended. However when i have more data and needs the rank for a specific column i wouldn't be able to do this anymore, so i'm wondering why the first formula doesn't work? Thank you.
1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: RANKX problem

Hi @sliu7 ,

 

The syntax of RANKX function is like this format :RANKX(<table>, <expression>[, <value>[, <order>[, <ties>]]]) ,the first argument is Table but not a Filed. You can go through the link https://docs.microsoft.com/zh-cn/dax/rankx-function-dax to learn more about the RANKX .

 

If you need to rank the value field for every countries categories, then try to create column in DAX below.

Rank= RANKX(FILTER(Sheet1,Sheet1[countries]=EARLIER(Sheet1[countries])),Sheet1[value],,ASC,Dense)

 

Best Regards,

Amy

 

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

4 REPLIES 4
Super User III
Super User III

Re: RANKX problem

@sliu7 

 

You need a calculated column? Not a measure...right?

 

Try this as column

 

Rank =
RANKX (
    ALLSELECTED ( Sheet1[countries] ),
    CALCULATE (
        SUM ( Sheet1[value] ),
        FILTER ( Sheet1, Sheet1[countries] = EARLIER ( Sheet1[countries] ) )
    )
)
Try my new Power BI game Cross the River
Community Support Team
Community Support Team

Re: RANKX problem

Hi @sliu7 ,

 

The syntax of RANKX function is like this format :RANKX(<table>, <expression>[, <value>[, <order>[, <ties>]]]) ,the first argument is Table but not a Filed. You can go through the link https://docs.microsoft.com/zh-cn/dax/rankx-function-dax to learn more about the RANKX .

 

If you need to rank the value field for every countries categories, then try to create column in DAX below.

Rank= RANKX(FILTER(Sheet1,Sheet1[countries]=EARLIER(Sheet1[countries])),Sheet1[value],,ASC,Dense)

 

Best Regards,

Amy

 

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

Community Support Team
Community Support Team

Re: RANKX problem

Hi  @sliu7 ,

 

Does that make sense? If so, kindly mark my answer as a solution to help others having the similar issue and close the case. If not, let me know and I'll try to help you further.

 

Best regards

Amy

sliu7 Frequent Visitor
Frequent Visitor

Re: RANKX problem

Thank you for your explanation Amy, it was helpful.

Helpful resources

Announcements
Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors