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
PVS07
Helper III
Helper III

Power BI sorting - Keep specific row at the bottom of the table when sorting by value

I would like to create a table in Power BI where I would to keep one specific row at the bottom regardless of the value.

For example, I want a table with top 15 countries in descending order and the all the other countries that have been grouped to "Other countries" as the last row. When I tried to create a table in Power BI the "Other countries" shows up in fourth position based on the value, however I would like to have it as the last row. Please see the screenshot below for reference.

 

Can anyone please let me know if it is possible to do this in Power Bi and how to do this. Thank you.

 

Sample data:

CountryNumber
Country 11,213
Country 21,086
Country 3718
Country 4448
Country 5394
Country 6186
Country 7171
Country 8133
Country 9131
Country 10121
Country 1192
Country 1267
Country 1345
Country 1439
Country 1539
Other countries466

Table sort.png

 

 

2 ACCEPTED SOLUTIONS
v-angzheng-msft
Community Support
Community Support

Hi, @PVS07 

 

You can create a sorted table, then establish a one-to-many relationship between the sorted table and the main table, use the RELATED function to create a sort column in the main table, and finally make the country column sort by the sort column.

 

refer:

https://community.powerbi.com/t5/Desktop/sort-months-into-chronological-order/m-p/2007639#M755993

 

 

Hope this helps.

 

Best Regards,
Community Support Team _ Zeon Zheng
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

v-angzheng-msft
Community Support
Community Support

Hi, @PVS07 

 

Sorry for not understanding your question correctly before😫

 

Try to create a measure like this:

 

_rank =
VAR _rank =
    RANKX (
        FILTER ( ALL ( 'Table' ), 'Table'[Country] <> "Other countries" ),
        CALCULATE ( SUM ( [Number] ) ),
        ,
        ASC,
        DENSE
    )
VAR _other =
    IF ( MAX ( 'Table'[Country] ) = "Other countries", 0, _rank )
RETURN
    _other

 

result:

vangzhengmsft_1-1629711722398.png

Please refer to the attachment below for details

 

Hope this helps.

 

Best Regards,
Community Support Team _ Zeon Zheng
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

7 REPLIES 7
tschris
Regular Visitor

An alternative solution to short the Other option I have implemented and added the code and the files here

v-angzheng-msft
Community Support
Community Support

Hi, @PVS07 

 

Sorry for not understanding your question correctly before😫

 

Try to create a measure like this:

 

_rank =
VAR _rank =
    RANKX (
        FILTER ( ALL ( 'Table' ), 'Table'[Country] <> "Other countries" ),
        CALCULATE ( SUM ( [Number] ) ),
        ,
        ASC,
        DENSE
    )
VAR _other =
    IF ( MAX ( 'Table'[Country] ) = "Other countries", 0, _rank )
RETURN
    _other

 

result:

vangzhengmsft_1-1629711722398.png

Please refer to the attachment below for details

 

Hope this helps.

 

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

Thanks for the detail and the calculated measure. 

v-angzheng-msft
Community Support
Community Support

Hi, @PVS07 

 

May I ask if your problem has been solved? Is the above post helpful to you?
If it helps, could you please mark the post which help you as Answered? It will help the others in the community find the solution easily if they face the same problem with you. Thank you.😀

 

Best Regards,
Community Support Team _ Zeon Zheng

v-angzheng-msft
Community Support
Community Support

Hi, @PVS07 

 

You can create a sorted table, then establish a one-to-many relationship between the sorted table and the main table, use the RELATED function to create a sort column in the main table, and finally make the country column sort by the sort column.

 

refer:

https://community.powerbi.com/t5/Desktop/sort-months-into-chronological-order/m-p/2007639#M755993

 

 

Hope this helps.

 

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

Thanks for the link. This is what I was looking for.

mahoneypat
Employee
Employee

Please see this article with a good way to do this.

Filtering the top products alongside the other products in Power BI - SQLBI

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.