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
Mal_Sondh
Helper II
Helper II

Create Top N based on additional filtering criteria

Hi All,

 

I have the following example data input (Table Name = :

 

NameURLCount
News - Home100
News Weather50
Sport - Home Page1000
Sport Football950
Sport Cricket600
Sport Snooker20

 

I have applied the following formula to get ranking:

Top Ranked Pages = RANKX(ALL(PageRefTable[Name],[URLCount]),,DESC,DENSE)

 

And this provides me with the following

Top Ranked Pages

NameURL CountTop Ranked Pages
Sport - Home10001
Sport Football9502
Sport Cricket6003
News - Home1004
News Weather505
Sport Snooker206

 

When i then apply a filter on the data and remove all items which contains "Home", the table then changes as follows:

 

NameURL CountTop Ranked Pages
Sport Football9502
Sport Cricket6003
News Weather505
Sport Snooker206

As you can see the ranking is then not continuous from 1, because what i want to see in the visual are the top 10 and i would use a condition such as Show me all data where the Top Ranked Pages <=10, in the case above it will not work as the ranking is at a different level.

I need a formula which replicates what i am doing in the visual - by ranking and including a filter criteria to not rank the records that contain the word "Home" - how can this be done?

I know there is a way to add a filter to the query, but what is the exact syntax to get the following result:

 

NameURL CountTop Ranked Pages
Sport Football9501
Sport Cricket6002
News Weather503
Sport Snooker204

 

Any help would be appreciated...

 

thanks in advance.

4 REPLIES 4
Fowmy
Super User
Super User

@Mal_Sondh 


Use this measure to get the correct Ranking: 

Top Ranked Pages = RANKX(ALLSELECTED(PageRefTable[Name]),[URLCount],,DESC,DENSE)

 

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hi,

 

You can get using allselected. Below is the snapshot for your ref.

 

Function : 

Rank = RANKX(ALLSELECTED(Data),[Urlsum],,DESC)

 

nvprasad_0-1603626375455.png

 

Appreciate a Kudos! 🙂
If this helps and resolves the issue, please mark it as a Solution! 🙂

Regards,
N V Durga Prasad

 

@nvprasad @Fowmy  

Thanks for the update - the calculation adjustment works up until this use case where there are multiple records that have the same count - the rank is then always the same.  Is there anyway to always just get a continous RANK rather than duplicates

 

For instance if the input data was 

NameURL Count
News - Home100
News Weather50
Sport - Home Page1000
Sport Football950
Sport Cricket600
Sport Tennis600

 

Then the ranking will come out as follows:

 

NameURL CountTop Ranked Pages
Sport - Home Page10001
Sport Football9502
Sport Cricket6003
Sport Tennis6003
News - Home1004
News Weather505

 

Rank 3 is replicated, is there anyway to Rank based on contunious numbering?

In this example if i say show me <=Rank 3, this will show 4 records as opposed to the top 3 - How can i only show the top 3 in a chart?

 

Thanks!

Hi @Mal_Sondh ,

 

I doubt you could get that. The question is that "Sport Cricket" and "Sport Tennis" are both third place, which one you want to show on the visual?

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

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.