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
olimilo
Responsive Resident
Responsive Resident

RANKX always returns 1

I've already inspected the other threads with the same dilemma, but most of them are running with SUMs of a numeric column. I'm trying to get the rank of an item through the number of instances it has appeared on the table (ie: COUNTROWS). Using the formula below, I always get a 1 on my Rank.

 

I'm pretty sure I've no problems with the [# of Violations] not having a CALCULATE since it's already a calculated measure, which seems to be the cause of the problem most of the posts for RANKX. I'd like to point out that I'm also using Page-level filters, unsure if this will affect the measure in any way.

 

 

' Measure
# of Violations = COUNTROWS(Violations)

' Measure
Rank = 
    RANKX(
        ALLSELECTED('Violations'),
        [# of Violations], , DESC, Dense
    )

 

Below is the expected result from the sample data:

 

Violation2017Rank2018Rank
A6172
B4381
C5253

 

SiteViolationInspectedYear Inspected
A1A1/1/20172017
A1B1/1/20172017
A2C1/1/20172017
A3A1/1/20172017
A1B1/1/20172017
A2C1/1/20172017
A3A1/1/20172017
A1B1/1/20172017
A2C1/1/20172017
A3A1/1/20172017
A1B1/1/20172017
A2C1/1/20172017
A3C1/1/20172017
A1A1/1/20172017
A3A1/1/20172017
A1A1/1/20182018
A2B1/1/20182018
A3C1/1/20182018
A1A1/1/20182018
A1B1/1/20182018
A2C1/1/20182018
A3A1/1/20182018
A1B1/1/20182018
A3C1/1/20182018
A1A1/1/20182018
A2B1/1/20182018
A1C1/1/20182018
A1A1/1/20182018
A2B1/1/20182018
A3B1/1/20182018
A1B1/1/20182018
A2A1/1/20182018
A3A1/1/20182018
A1B1/1/20182018
A2C1/1/20182018

 

Would like to know how to solve this. Any input is definitely appreciated.

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

Hi @olimilo

 

A tiny change in your formula is needed Smiley Wink

 

Rank =
RANKX ( ALLSELECTED ( Violations[Violation] ), [# of Violations],, DESC, DENSE )

 


Regards
Zubair

Please try my custom visuals

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

 

This too should work

 

=RANKX ( ALL ( Violations[Violation] ), [# of Violations],, DESC, DENSE )

 

I dont think the ALLSELECTED function is required.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
mattbrice
Solution Sage
Solution Sage

Please try replacing your ALLSELECTED statement with this

 

ALLSELECTED('Violations'[Violation] )
olimilo
Responsive Resident
Responsive Resident

Thanks for the help everyone! Although I find it weird that I had to indicate the column I'm going to be working on. I thought that using it on the measure would be enough.

 

Zubair_Muhammad
Community Champion
Community Champion

Hi @olimilo

 

A tiny change in your formula is needed Smiley Wink

 

Rank =
RANKX ( ALLSELECTED ( Violations[Violation] ), [# of Violations],, DESC, DENSE )

 


Regards
Zubair

Please try my custom visuals

@olimilo

 

8001.png


Regards
Zubair

Please try my custom visuals

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.