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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Gombosf
New Member

Issues with RANKX

Dear Members!

 

I have been assigned to build up a database in SharePoint and for the graphical surveys we would use Power BI. have never used this software before so I'm trying to get familiar with it. I'm struggling now with achieving the proper ranking in my document (in the table -name of it is "Table1"- that I've created). I'm just testing this command, because I assume that the usage of this command can be a root cause of a further problem that I'm still facing with.

 

I defined the "Value" variable on my own (I just filled out the variable with random integers) and I had the feeling that the values of the variable need to be converted into a measure variable first ("Value" -> "Total_value").

So I created an other variable ("Total_value") shown below:

Total_value = SUM(Table1[Value])

 

Thus I'd have liked to achieve a proper ranking for the "Total_value" variable. Unfortunately I'm not allowed to upload screenshots of the issue, but I share with you the result of the ranking: 35 (1), 24 (2), 34 (2), 21 (4), 19 (5), 13 (6), 10 (8), 9 (9), 8 (10), 6 (11), .. 

 

As you can see, it's not correct (you can find the ranking order in the brackets -> two values were ranked to the 2nd place and thus the 3rd place is missing, plus the 7th place is missing, too).

I tried to rank the values of the “Total_value” variable as follows:

Ranking_value = RANKX(ALL(Table1), [Total_value])

 

I can summarize the issue in a table-form:

Name

Value

Total_value

Ranking_value

Cx

35

35

1

Ca

24

24

2

Vf

34

34

2

qa

21

21

4

íy

19

19

5

Dsb

13

13

6

Bvx

10

10

8

Bxe

9

9

9

H

8

8

10

W

6

6

11

Nbg

4

4

12

F

3

3

13

V

2

2

14

 

Does anyone have an idea what can be the problem, and could you please help me out?

 

Many thanks.

Regards,

Fruzsina

2 ACCEPTED SOLUTIONS
CNENFRNL
Community Champion
Community Champion

Hi, @Gombosf , you might want to try this measure

 

Rank = RANKX(ALLSELECTED(Table1[Name]), [Total_value])

 

 

In fact, the mechanism of RANKX() under the hood is way much trickier than it appears. Here are some links for your further study if you're looking to master this most frequently-used function in DAX and to put it in your quiver.

https://docs.microsoft.com/en-us/dax/rankx-function-dax

https://www.sqlbi.com/articles/use-of-rankx-in-power-bi-measures/


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

amitchandak
Super User
Super User
3 REPLIES 3
amitchandak
Super User
Super User

Dear @CNENFRNL  and @amitchandak !

 

Thank you for your help.

I think the main issue with the RANKX command was that I didn't use a separate table for the command. I feel this reason responsible for the wrong ranking order. 

 

I hope that you can see the picture attached.

Gombosf_0-1607412264058.png

If this is the reason for the wrong ranking order, then I don't really understand the behaviour of the RANKX command (I have no clue why is it necessary to create a brand new table for having this ranking in a right way). Maybe this comes simply from the nature of the command. 🙂

 

Many-many thanks.

 

CNENFRNL
Community Champion
Community Champion

Hi, @Gombosf , you might want to try this measure

 

Rank = RANKX(ALLSELECTED(Table1[Name]), [Total_value])

 

 

In fact, the mechanism of RANKX() under the hood is way much trickier than it appears. Here are some links for your further study if you're looking to master this most frequently-used function in DAX and to put it in your quiver.

https://docs.microsoft.com/en-us/dax/rankx-function-dax

https://www.sqlbi.com/articles/use-of-rankx-in-power-bi-measures/


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors