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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Jaspreet99
Advocate I
Advocate 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).

I tried using "Sort by Column" option, but it’s not working properly in my case.

 

1 ACCEPTED SOLUTION
rohit1991
Super User
Super User

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.


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

View solution in original post

3 REPLIES 3
mizan2390
Resolver II
Resolver II

You solve the problem in two ways. Either in Power Query or in Calculated Column. Better to do this in Power Query if your data model is large in size.
in Power Query,
Add Column >> Conditional Column >> Name the column like "Category Index" and set the value as required. 

mizan2390_0-1757776521900.png

or to create in Calculated Column

 

Table View >> Table Tools >> New Columns >>

Category Index=
SWITCH (
    TRUE(),
    Data[Category] = "High", 1,
    Data[Category] = "Medium", 2,
    3
)
now click on the category column, >>  go to sort by column >> selecet the Category Index , column to sort
mizan2390_1-1757776910752.pngmizan2390_2-1757776958998.png

If this solved your issue,  please Give a Kudo and Mark as Solution. Thank You

 

MasonMA
Super User
Super 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'.

 

rohit1991
Super User
Super User

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.


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.