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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
newpbiuser01
Helper V
Helper V

Slicer Custom Sort

Hello,

 

I need to create a custom sort based for a slicer where the values are going to be all the fruits in the dataset and also an "All Fruits" option. I need to sort the column so the "All Fruits" is always on the top and the remaining values in the column are sorted automatically in an alphabetical order. I tried creating a conditional column to assign a sort ID but that wouldn't account for any new fruits being added in the data set. So for example if "Peach" was added to the dataset in the next month, it would automatically be assigned the SortID 3 and the following fruits would move down in the list. 

Cell ValueSortID
All Fruits1
Apple2
Pear3
Orange4

 

Thank you!

 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You could create a table which will add new values when they appear as

New Table = 
var fruits = VALUES('Table'[Fruit])
return UNION( 
ADDCOLUMNS( fruits, "Sort order", RANKX(fruits, [Fruit], , ASC),
{ ( "All fruits", -1) }
)

View solution in original post

2 REPLIES 2
v-easonf-msft
Community Support
Community Support

Hi, @newpbiuser01 

'SortID' column is recalculated and created every time the data is refreshed.

If you want to automatically assign a Sort ID based on the time the record was added, then you have to consider adding a datetime column in your original datasoure as the basis for adding the SortID.

 

Best Regards,
Community Support Team _ Eason

johnt75
Super User
Super User

You could create a table which will add new values when they appear as

New Table = 
var fruits = VALUES('Table'[Fruit])
return UNION( 
ADDCOLUMNS( fruits, "Sort order", RANKX(fruits, [Fruit], , ASC),
{ ( "All fruits", -1) }
)

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors