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
shelbsassy
Resolver I
Resolver I

RANKX for Top 5 Facilities by number of successes

I am new to Power BI and I have looked and tried everything to get the Rankx function to try and display the top 5 nursing facilities by the number of success counts for each. 

 

Basically I have (Sheet1[Nursing Facility]) which is what I am trying to dsplay the top 5 of

Then I have (Sheet1[Success Count] which is a calculated column that is: Success Count = IF(Sheet1[status_id]=1||Sheet1[status_id]=4,1,0)

 

How can I get the top 5 facilities displayed like this:

 

Frontier Health and Rehab            9

St Louis Place Health & Rehab     4

Autumn Terrace Health                3

Lees Summit Pointe Health          3

Riverbend Heights                       2

 

Thanks for any help!

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

@shelbsassy It sounds like you want to RANK the Nursing Facilites by the SUM of the results in the Success Count Column?

 

If so -  I would suggest:

1) Create a SUM Measure

 

Success SUM Measure = SUM ( Sheet1[Success Count] )

2) Then create your Ranking Measure

 

RANK Facilities = RANKX ( ALL(Sheet1[Nursing Facility]), [Success SUM Measure])

NOTE => If you combine steps 1 and 2 you would HAVE TO wrap the sum in calculate

 

RANK Facilities 2 = RANKX ( ALL(Sheet1[Nursing Facility]), CALCULATE ( SUM (Sheet1[Success Count]) ) )

 

3) Finally go in the Visual Level Filters => select RANK Facilities => Show items when the value is: less than or equal to 5

 

2016-09-30 - RANK.png

 

Hope this helps! Smiley Happy

Next step would be to determine what measure you want to use to break the ties?

 

EDIT: Forgot to wrap the whole thing in IF ( HASONEVALUE => so you don't rank the total row!

 

RANK Facilities =
IF (
    HASONEVALUE ( Sheet1[Nursing Facility] ),
    RANKX ( ALL ( Sheet1[Nursing Facility] ), [Success SUM Measure] )
)

 

View solution in original post

4 REPLIES 4
shelbsassy
Resolver I
Resolver I

WOW Thank you so much!  That worked perfectly!!  Appreciate your fast response 🙂

@shelbsassy

 

If your problem has been solved, you could mark the right answer as solution to close this thread. Smiley Happy

 

Best Regards,

Herbert

Sean
Community Champion
Community Champion

@shelbsassy It sounds like you want to RANK the Nursing Facilites by the SUM of the results in the Success Count Column?

 

If so -  I would suggest:

1) Create a SUM Measure

 

Success SUM Measure = SUM ( Sheet1[Success Count] )

2) Then create your Ranking Measure

 

RANK Facilities = RANKX ( ALL(Sheet1[Nursing Facility]), [Success SUM Measure])

NOTE => If you combine steps 1 and 2 you would HAVE TO wrap the sum in calculate

 

RANK Facilities 2 = RANKX ( ALL(Sheet1[Nursing Facility]), CALCULATE ( SUM (Sheet1[Success Count]) ) )

 

3) Finally go in the Visual Level Filters => select RANK Facilities => Show items when the value is: less than or equal to 5

 

2016-09-30 - RANK.png

 

Hope this helps! Smiley Happy

Next step would be to determine what measure you want to use to break the ties?

 

EDIT: Forgot to wrap the whole thing in IF ( HASONEVALUE => so you don't rank the total row!

 

RANK Facilities =
IF (
    HASONEVALUE ( Sheet1[Nursing Facility] ),
    RANKX ( ALL ( Sheet1[Nursing Facility] ), [Success SUM Measure] )
)

 

Greg_Deckler
Super User
Super User

Is the number in your table the Success Count? I do not see how you could get a Success Count like that from the formula you are providing for Success Count. It seems like it would either be 1 or 0. Or are you saying that you have multiple rows of the same facility and essentially want to summarize them in a table? 

 

I *think* if it is the later, you might have to use something like SUMMARIZE.

 

Actually, take a look at this article:

http://www.powerpivotpro.com/2015/06/rankx-apalooza-within-and-across-groups-with-filters-etc/

 

And take a look at the section "Ranking by Non Unique Columns"


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.