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
PaulBethancourt
Frequent Visitor

Rankx is Incorrect when similar ranked column added to table

I'm using RANKX to rank the number of "Monthly Lines" based on a column called "Parent and TC City".

PaulBethancourt_0-1677774376749.png

The above rank work fine.
If I add the field "Parent Org" to the table, then the ranking is incorrect:

PaulBethancourt_1-1677774571019.png

My measure for rank is:

Rank Parent City = RANKX(all(SCM_RMA_METRICS[Parent and TC City]),calculate([Monthly Lines]))
Any idea what's going on here?
Any help would be appreciated!
Link to Sample Rankx problem  https://1drv.ms/u/s!Aq5dyjpfjB3Ug9xgh8R7OSESIUJGww?e=HJ7idb 
1 ACCEPTED SOLUTION
grantsamborn
Solution Sage
Solution Sage

Hi @PaulBethancourt 

Would something like this help?

 

Rank TC Parent City 2 = 
RANKX(
    ALL( 'Table'[Parent and TC City], 'Table'[Parent Org] ),
    [Monthly Lines]
)

 

It seems to work in both of your scenarios.

Let me know how this works.

 

pbix: Rankx Problem.pbix

View solution in original post

5 REPLIES 5
Padycosmos
Solution Sage
Solution Sage

If you are using a Matrix Visual, this video would help:

https://www.youtube.com/watch?v=y2FFjfRD-Bo

IF you are using a Table Visual, this video would help:

https://www.youtube.com/watch?v=tS1ff6ouORg

dilshad_ahmed
Frequent Visitor

@PaulBethancourt 

It is because when you are including Parent Org, the context is getting changed. To avoid the context change you can use a table in your Rank Dax by cross joining the 'Parent and TC City' and 'Parent Org'. I have verified it and it gives the correct result. 

dilshad_ahmed_0-1678034935886.png

My Dax looks like 

Rank TC Parent City = RANKX(CROSSJOIN(ALL('Table'[Parent and TC City]),ALL('Table'[Parent Org])),[Monthly Lines])
You can also refer the below youtube video for understanding:
Hope it helps!

 

grantsamborn
Solution Sage
Solution Sage

Hi @PaulBethancourt 

Would something like this help?

 

Rank TC Parent City 2 = 
RANKX(
    ALL( 'Table'[Parent and TC City], 'Table'[Parent Org] ),
    [Monthly Lines]
)

 

It seems to work in both of your scenarios.

Let me know how this works.

 

pbix: Rankx Problem.pbix

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

I posted the link to the Power BI that shows the problem - Thanks

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.