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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
alefebvre
New Member

Ranking error (sort column)

Hello,

I must put the number of typologies per group, and then do the top 5 typologies. With some research I ended up finding the RANKX function which thanks to a filter <= 5 allows me to display the 5 largest values.

 

I was then asked to put 2 specific typologies at the end of the table, so I created an INDEX column which allowed me to set a value to 1 by default and 1000, 1001 on the one to be at the end.

 

alefebvre_0-1620209507684.png

 

Once the INDEX value is set I configure the sort:

alefebvre_1-1620209754415.png

 

 

Then here is my measurement which allows me to have the RANK:

TYPO RANG = RANKX( ALL(TYPOLOGIES[TYPO]), MESURES[TYPO COUNT], , DESC)
 
And the table that appears, the ranks are correct except for the typos (CAR and INC) which are the one to rank at the end with an index at 1000 & 1001
alefebvre_2-1620209912976.png

 

Do you have a solution for me so that the RANK does not put them in 1st position ?
 
Thank you in advance !
 
1 ACCEPTED SOLUTION
alefebvre
New Member

Hello,

Thank you for your help, I think it does not work for me because I go through a measure to count the number of typologies.

 

I found a solution on this site : https://www.sqlbi.com/articles/use-of-rankx-in-power-bi-measures/

 

Here is what I did in the method RANKX : TYPO RANG = RANKX( ALL(TYPOLOGIES[Index], TYPOLOGIES[TYPO]), MESURES[TYPO COUNT], , DESC)

 

Have a good day 🙂

View solution in original post

2 REPLIES 2
alefebvre
New Member

Hello,

Thank you for your help, I think it does not work for me because I go through a measure to count the number of typologies.

 

I found a solution on this site : https://www.sqlbi.com/articles/use-of-rankx-in-power-bi-measures/

 

Here is what I did in the method RANKX : TYPO RANG = RANKX( ALL(TYPOLOGIES[Index], TYPOLOGIES[TYPO]), MESURES[TYPO COUNT], , DESC)

 

Have a good day 🙂

v-yingjl
Community Support
Community Support

Hi @alefebvre ,

Could not reproduce it in my side. How did you create the index column and the [TYPO COUNT] measure?

Could you please consdier sharing more details about it or a simple sample file without any sesentive information for further discussion?

 

Attached my test sample file in the below, you can also change it based on the sample file.

 

Best Regards,
Community Support Team _ Yingjie Li

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors
Top Kudoed Authors