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
NNaj
Helper IV
Helper IV

RANKX measure is ranking data from a relationship table that is not in my dataset

Hi All,

I have written this measure to rank my ID entries based on hit %.

Current Quarter Ranking = RANKX(DEXTR, [Hit %])

In another table, I have ID's and company names to help identify which companies are being referred to. In this table there are more companies and ID's than in dataset. This is where I believe my problem is arising. (e.g. ID 1 is company A, ID 2 is company B,..)

When I add the measure above to my table, it adds rows to my table for the other companies not referred to in my dataset. How can I avoid this?

The image below shows how the ranking is: 1) incorrect order (I want the highest % to be ranked higher). 2) Ranking extends for the CP_ID beyond those in the data set because of the above mentioned relationship table where I extract the company name from the ID.rank help.png


Any help will be appreciated.

Thank you in advance.

 

1 ACCEPTED SOLUTION
Washivale
Resolver V
Resolver V

Hi @NNaj ,

 

Try this

 

Calc_Rank = Rankx( All(Table[CP_ID]), Calculate([Hit%]))

 

let me know if it works.

 

Thanks,

Washivale

View solution in original post

7 REPLIES 7
Stemar_Aubert
Resolver I
Resolver I

You can check out how to use CALCULATE here : https://www.absentdata.com/power-bi/how-to-use-calculate-in-power-bi/ 

 

What I like to do with RANKX is to nest it within a CALCULATE function, so I can apply filters to it easily.

 

For exemple, in your model you can try 

 

CQR = Calculate(rankx(allselected([DEXTR]),[HIT %]))

 

Which will only take what is currently selected on your page.

HI @Stemar_Aubert 

 

Thanks for the help,

 

Unfortunately im still having the same issues.

 

 

v-diye-msft
Community Support
Community Support

Hi @NNaj 

 

Take a try of this measure: 

Current Quarter Ranking = RANKX( All(DEXTR[CP_ID]), [Hit%],,,Dense)
Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

Hi @v-diye-msft ,

 

Thanks for your message. I tried this but im still having the same problem.

 

Washivale
Resolver V
Resolver V

Hi @NNaj ,

 

Try this

 

Calc_Rank = Rankx( All(Table[CP_ID]), Calculate([Hit%]))

 

let me know if it works.

 

Thanks,

Washivale

Hi @Washivale 

 

I am still having the same problem where the CP_IDs are shown from the table there is a relationship with. Also, the ranking displays all 1's.

 

Washivale solution.png

Hi @NNaj ,

 

Which table column are you using in "ALL(Table[CPI_ID])" part of the function. Is it your current table or the second table where you have all ID's. Try creating two measures using both the options and let me know if outcome of both is same.

 

thank you,

Washivale

 

 

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