Forum Discussion
Jaspreet99
11 months agoAdvocate I
Sorting issue
Hi I have a column with categories (for example: High, Medium, Low) but by default Power BI sorts them alphabetically. I want them to appear in my visuals as High, Medium, Low (not alphabetical). ...
- 11 months ago
Hi Jaspreet99
In Power BI, text fields sort alphabetically by default. To apply a custom sort order (High >> Medium >> Low):
1. Create a SortOrder column (numeric) like:
High = 1
Medium = 2
Low = 3
2. Create column:
SortOrder = SWITCH ( TRUE(), Categories[Category] = "High", 1, Categories[Category] = "Medium", 2, Categories[Category] = "Low", 3, 4 )3. Select the Category column >> Column tools >> Sort by Column >> choose SortOrder.
Now visuals will show High >> Medium >> Low instead of alphabetical.
MasonMA
11 months agoSuper User
Or, in Power Query create a numeric column that represents the desired order
= Table.AddColumn(
PreviousStep,
"SortOrder",
each if [Category] = "High" then 1
else if [Category] = "Medium" then 2
else if [Category] = "Low" then 3
else 99
)
Then in Data view select the Category column, sort by Column 'SortOrder'.