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
Uzi2019
Super User
Super User

Rank top 10 city & rest should be display as others

Hi Experts,

 

I want to display only top 10 city and rest of the city should be display as "others". I want to show in pie chart where only 11 values should be display top 10 city +other values.

I am not able to set rank to my city column. it is showing all 1 rank to all city.

 

Thanks in advance.

 

Capture.PNG

Don't forget to give thumbs up and accept this as a solution if it helped you!!!
2 ACCEPTED SOLUTIONS

hi  @Uzi2019 

Try this formula to create a column

regionrank = VAR a= RANKX(Facebook,CALCULATE(SUM([Impressions]),ALLEXCEPT(Facebook,Facebook[Region])),,DESC)
return
IF(a>=11,"Others",Facebook[Region])

or

regionrank = 
VAR a= RANKX(Facebook,CALCULATE(SUM([Impressions]),FILTER(Facebook,Facebook[Region]=EARLIER(Facebook[Region]))),,DESC)
return
IF(a>=11,"Others",Facebook[Region])

 

If not your case, please share your sample pbix file for us have a test.

 

Regards,

Lin

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

View solution in original post

HI @Uzi2019 ,

 

Create a calculated Column

 

SumValuesCOl = CALCULATE(SUM('Table'[Values]), FILTER (ALLEXCEPT('Table','Table'[region]), NOt(ISBLANK('Table'[region]))))

 

 

Create another Calculated Column

 

regionrank =
VAR a=

IF(NOT(ISBLANK('Table'[region])),
RANKX(SUMMARIZE('Table','Table'[SumValuesCOl]),'Table'[SumValuesCOl]))
return
IF (a>10, "Others", CONVERT(a,STRING))
 
 
1.jpg
 
 
 
2.JPG
 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

View solution in original post

14 REPLIES 14
harshnathani
Community Champion
Community Champion

Hi @Uzi2019 ,

 

Use this measure

 

Ranking =

 

 

var a = RANKX(ALL('Table'[Region]), Calculate (Sum('Table'[Impressions]))
RETURN
IF (a>10, "Others", CONVERT(a,STRING)

 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

@harshnathani ,

Thanks a lot for your answer. It's working as expected but unable to display in pie chart.

Because Your given measure is not added into "Legend" property of Pie chart.

 

Please assist further as we are almost close.

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

@Uzi2019 ,

 

I do not think that you can use measures in Legend of a pie chart.

 

You have to create a Calculated Colum incase you want to use this as a legend.

 

 

Regards,

Harsh Nathani

 

@Uzi2019 ,

 

Rank Column = 

 

var a = RANKX(Table', Calculate (Sum('Table'[Impressions]))
RETURN
IF (a>10, "Others", CONVERT(a,STRING)

 

Regards,

Harsh Nathani


Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

@harshnathani ,

I tried your Rank Column but it gives me circular dependency.

Capture.PNG

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

@harshnathani ,

I replaced ALL with ALLSELECTED so circular dependency has removed. but not showing "Others" values in calculated column.

 

Capture.PNG

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

HI @Uzi2019 ,

 

Create a calculated Column

 

SumValuesCOl = CALCULATE(SUM('Table'[Values]), FILTER (ALLEXCEPT('Table','Table'[region]), NOt(ISBLANK('Table'[region]))))

 

 

Create another Calculated Column

 

regionrank =
VAR a=

IF(NOT(ISBLANK('Table'[region])),
RANKX(SUMMARIZE('Table','Table'[SumValuesCOl]),'Table'[SumValuesCOl]))
return
IF (a>10, "Others", CONVERT(a,STRING))
 
 
1.jpg
 
 
 
2.JPG
 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

@harshnathani 

 

Thank you so much. it really solved my issue..

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

hi  @Uzi2019 

Try this formula to create a column

regionrank = VAR a= RANKX(Facebook,CALCULATE(SUM([Impressions]),ALLEXCEPT(Facebook,Facebook[Region])),,DESC)
return
IF(a>=11,"Others",Facebook[Region])

or

regionrank = 
VAR a= RANKX(Facebook,CALCULATE(SUM([Impressions]),FILTER(Facebook,Facebook[Region]=EARLIER(Facebook[Region]))),,DESC)
return
IF(a>=11,"Others",Facebook[Region])

 

If not your case, please share your sample pbix file for us have a test.

 

Regards,

Lin

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

@v-lili6-msft / @harshnathani 

 

Please find the pbix file on below link..

https://drive.google.com/file/d/1nNSktMkDxrgLyyz0fZCnZwJxjOgyPrTw/view?usp=sharing

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

@Uzi2019 ,

 

Please share you pbix or sample data.

 

Upload on One Drive or share via Google Drive.

 

Regards,

Harsh Nathani

parry2k
Super User
Super User

@Uzi2019 for rank , read these posts

 

https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures

 

and for top 10, check this post, hope it helps

 

https://community.powerbi.com/t5/Desktop/Top-10-Other/td-p/51282

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k 

 

I am unable to figure out how to get 11th value as "others" value in cloumn with top 10 values..

I got the rank but unable to find the next step to calculate "Others".

Capture.PNG

When I apply below DAX it gives me error:

rank2 = IF([rank]<=10,Facebook[Region],"Others")
 
Any help would be highly appreaciated. 

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

@Uzi2019 ,

 

You will need to convert the numeric rank value to Text.

 

var a = RANKX(ALL('Table'[Region]), Calculate (Sum('Table'[Impressions]))
RETURN
IF (a>10, "Others", CONVERT(a,STRING)

 

Regards,

Harsh Nathani

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.