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
Anonymous
Not applicable

RANKX incorporating legend but retaining overall rank

Hi everyone,

 

I'm having trouble displaying a ranking and incorporating a legend that doesn't do a seperate ranking for each item in the legend.

 

I have successfully ranked individuals (Appointment_Key) based on an income value (Apportioned award amount) using the DAX:

M: Rank =
RANKX(ALLSELECTED(VW_Denorm_DIM_Appointment[HR_Appointment_Key]), CALCULATE(SUMX(VALUES(VW_Denorm_DIM_Appointment[HR_Appointment_Key]),FACT_RGC_Project_Status_History[M: Apportioned award value])),,,Skip)
 
When I then incorporate gender into the legend, with the aim of retaining the overall ranking, but colouring individuals by gender, the ranking is then done within each gender and both displayed on the same chart, with more a person of each gender taking up a 1st place, 2nd place etc.
 
2 rankings when adding a legend.2 rankings when adding a legend.
Gender is stored in another table, DIM_Person, adjacent to the Appointment table.
 
I've looked over various solutions here, including ALL(Gender), and tried a summarize function as the RANX table expression, but nothing is working. I either end up with everyone ranked 1, or I get back to the double-ranked chart.
 
Any help greatly appreciated!
 
Of note:
I am using an on-site server-optimised version of Power BI (may not be the correct terminology), so not all DAX or Power BI functions are available to me (I saw another solution very similar to mine utilising ISINSCOPE, which I don't have available to me on the server-optimised version, and I can't use Power BI's grouping function. I can add columns into the original data tables, but not alculated columns via Power BI).
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Colleagues and I have just cracked it. In the RANX ALLSELECTED statement I was referencing a single column (person ID), but needed to just reference the whole table. Simple oversight on my part (although not immediately obvious!)

 

Thank you for your help. Reviewing your suggestions helped us get to the answer!

View solution in original post

8 REPLIES 8
v-gizhi-msft
Community Support
Community Support

Hi,

 

According to your description, i create two simple tables to test:

21.PNG22.PNG

Then create a rank measure:

Rank = RANKX(ALLSELECTED(Scores),CALCULATE(SUM(Scores[Scores])),,ASC,Skip)

Choose a table visual and it works well:

23.PNG

Then choose Scatter Chart visual, use [Gender] from another table, and it shows the total rank:

24.PNG

Here is my test pbix file:

pbix 

Hope this helps.

 

Best Regards,

Giotto Zhi

 

Anonymous
Not applicable

Hi Giotto,

 

Your logic makes sense, and I expected that behaviour when I created the charts, but nonetheless I still can't get my report to do what I need, even following the steps exactly. It is still seemingly doing the calculation for each gender and ranking them seperately. When I tabulate the results you can see this. I don't know if it's my model, or the DAX?

 

A difference I've just realised though is that unlike your scoring table, my 'Score' is a measure using a column from another dimension, rather than a column native to the table the person IDs are coming from. Is this possibly part of the issue?

 

Table 2.JPG

Hi,

 

I create two tables to test:

72.PNG71.PNG73.PNG

Then create a total score measure for each person:

Scores = SUM(Scores[ItemScores])

Create a rank measure:

rank = RANKX(ALLSELECTED(Person),[Scores],,DESC,Skip)

The result shows:

75.PNG

The rank still work well.

So could you tell me details about what the relationship among your tables?

 

Best Regards,

Giotto Zhi

Anonymous
Not applicable

Here is a diagram of the model:

Model.JPG

I've used your term score, which in my original post is 'Apportioned award value', and is a measure calculated using the 'Score' * an individuals % from the table I've labelled 'Intermediate table'.

Thank you for your continued help 🙂

Hi,

 

Could you please tell me more details about your tables' relationship such as one-to-one or one-to-many?

And please show the linked column between each two tables.

These info will help me solve your issue as fast as possible.

 

Best Regards,

Giotto Zhi

 

Anonymous
Not applicable

Model.JPG

I've included connecting fields in the above. Join types are illustrated in the connections - forks are many.

Thanks.

Anonymous
Not applicable

Colleagues and I have just cracked it. In the RANX ALLSELECTED statement I was referencing a single column (person ID), but needed to just reference the whole table. Simple oversight on my part (although not immediately obvious!)

 

Thank you for your help. Reviewing your suggestions helped us get to the answer!

Hi,

 

If my answer help solve your problem, please mark it as a solution.

Thanks.

 

Best Regards,

Giotto Zhi

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.