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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

RankX ranks stuff that does not exist

Hello!

I need help with my RANKX-function.
I have a facttable that looks like this:

einarrattgard_0-1629119568204.png

And my RANKX looks like this:

einarrattgard_3-1629119920096.png

I want to rank each date depending on OD

But when I create a table with the the Supplier Names instead of the supplierID, I get a table where each supplier is on each date, even though there is only one on each date in the facctable.

einarrattgard_2-1629119870230.png

Why is this happening and what can I do about it?

 

Thank you very much for any replies

8 REPLIES 8
amitchandak
Super User
Super User

@Anonymous , Try measure like

 

Rankx(allselected(Table[date],Table[Supplier name]), [Distance from selected %])

 

If you take any column other one used in rank , then rank will be inside that column

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak 

The problem unfortunately remains. Each [Date] still gets every [SupplierName] even though every date only have one supplier and they are connected via a relationship through [SuppllierID].

@Anonymous It likely has something to do with your ranking measure. What is the formula for it? Also, this may help:

To *Bleep* with RANKX! - Microsoft Power BI Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler 
I think the problems lies with my dim- and my fact-table.
Because when I use 'Suppliers'[SupplierName] instead of 'PurchaseFacts'[SupplierID], every date on 'PurchaseFacts' get a row for each supplier.
Any Idea?

@Anonymous Hard to say with the information provided. 

 

Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler 
I apoligize for not being clear enough. Will do my best to tackle this in the future. How do I upload my .pbix-file? 

 

1. I have a file but I don't know how to share it. 
2. The measure [Distance from OD %] gives a value to each date depending on a slicer, the code looks like this:

Distance from selected OD % = 
DIVIDE(
    ABS( MAX( PurchaseFacts[OD] ) - SELECTEDVALUE( 'OD Diameter'[OD Diameter] ) ),
    MAX(PurchaseFacts[OD])
)

This is just a measurement on how far away a date is from a selected value in a slicer. 
I want to order these by how large they are. 

Ranking OD Differance = 
RANKX( ALL(PurchaseFacts[Date]), [Distance from selected OD %] ,, ASC )

Nothing Strange this far. It looks like it should

einarrattgard_2-1629123226357.png

But when I replace SupplierID with SupplerName this happens:

einarrattgard_3-1629123263535.png

Every date get every supplier.
This is the relationship:

einarrattgard_5-1629123394614.png

 

Why is this happening? How can I prevent this?

How Do I upload my pbix-file?
 

@Anonymous Upload your PBIX to OneDrive, Box or any file sharing site and then share a link. Easiest, quickest way.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler 
https://drive.google.com/file/d/14KgNeBnTj0dmn7n7KXmZfAqSdpDL4thf/view?usp=sharing

Use this together with the schreenshots i provided before.
Thank you very much for helping me

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors