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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Grouping Data into Other Category

I have a set of data and I want to create a bar chart that returns the top 5 values and groups the rest into an "other" category.

 

How would I do this?

 

Capture.PNG

1 ACCEPTED SOLUTION
v-gizhi-msft
Community Support
Community Support

Hi,

 

Please try to create a rank column instead of rank measure:

Rank-Column = RANKX('Table','Table'[Revenue],,DESC,Dense)

Then create a new category column:

New Category = IF([Rank-Column]<=5,'Table'[Category],"Other")

Choose this [new Category] and original [Revenue] as a bar chart, it shows:

15.PNG

Here is my test pbix file:

pbix 

Hope this helps.

 

Best Regards,

Giotto Zhi

View solution in original post

4 REPLIES 4
cowboyracer
Frequent Visitor

@v-gizhi-msft 

Hi!

How does this, if it does at all, work for non values?

Say, we have a table with all the houses in town.
One column is the type of house and there are 35 different types of houses.

But 10 of them only occur once or twice.

I want to group them into a class "Other"

Can this be done too?

 

Kind regards,

Simone

v-gizhi-msft
Community Support
Community Support

Hi,

 

Please try to create a rank column instead of rank measure:

Rank-Column = RANKX('Table','Table'[Revenue],,DESC,Dense)

Then create a new category column:

New Category = IF([Rank-Column]<=5,'Table'[Category],"Other")

Choose this [new Category] and original [Revenue] as a bar chart, it shows:

15.PNG

Here is my test pbix file:

pbix 

Hope this helps.

 

Best Regards,

Giotto Zhi

Anonymous
Not applicable

Hi Giotto,

I am having the same problem. I figured out with your solution that the "Rank-Column" should give me a ranking of all the items on my list from 1 to 5. But when I copied and pasted the code you gave and changed the field name to match my project, it didn't work. First the program came up with a column called "Sum of Rank-Column" that was all 1's. Then when I told it not to summarize, it said it "Can't display the visual".

amitchandak
Super User
Super User

@Anonymous ,For Rank Refer these links - This will how to get it. Specially the first one
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
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-3-of-3-the-finale

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.