How to Custom Sort in Power BI Bar Chart?

Are you looking for a custom sort in the Power BI Bar Chart? If your requirement is yes, you must create a new Power BI table and manage their relationship.

I recently worked with a Power BI Bar chart where the requirement was to sort the bar chart in custom order. For that, I researched some solutions and implemented them in this article.

This Power BI tutorial will assist you with how to custom sort in Power BI bar chart with a simple example.

Power BI Bar Chart Custom Sort

In Power BI, changing the order of a bar chart means adjusting the sequence in which the bars are displayed.

Example:

I have a Power BI bar chart with the status order Waiting, In Progress, Completed, Deferred, and Not Started. Refer to the first image.

Now, I would like to sort the bar chart with a custom order like:

  • Not Started
  • In Progress
  • Wating
  • Deferred
  • Completed

Check out the second screenshot below.

How to Custom Sort in Power BI Bar Chart

We have a SharePoint list (Project List) that contains below columns with various data types:

ColumnsData Types
NameSingle line of text
ProjectSingle line of text
StatusSingle line of text
Custom Sort in Power BI Bar Chart

1. Open the Power BI Desktop and load the data. Then, we can see the data set in the Data pane.

How to Custom Sort Power BI Bar Chart

2. Now, under the Visualizations pane, click Stacked bar chart. Then, drag Status into the Y-axis and Product into the X-axis.

Custom sort orders in Power BI bar chart

This way, we create a Power BI Bar chart.

How to Custom Sort in Power BI Bar Chart

I will tell you how to apply custom sorting in the Power BI Bar chart.

Follow the instructions below to apply custom sorting to the Power BI Bar Chart:

  1. Create a lookup table in Power BI.
  2. In the lookup table, Sort by column ID for the Status column in Power BI.
  3. Using the Status column, manage the relationship between the new lookup table and the original table in Power BI.
  4. Create a bar chart using the lookup table in Power BI.

Create a Lookup Table in Power BI

Here, we create a new table with columns “ID” and “Status”. The ID for custom order and Status for the relationship between two tables.

1. Under the Home tab, click Enter data.

Power BI Bar Chart Custom Sort

2. In the “Create Table” dialog box, create ID columns as (1, 2, 3, 4, 5) and Status columns as (Not Started, In Progress, Wating, Deferred, and Completed). Then enter a table “Name.” and click the “Load” button.

how to custom sort bar chart in power bi

This way, we can create a new table in Power BI Desktop.

Sort by Column in Power BI

Now we sort the “Status” column using the simple steps:

  1. Click the Table view.
  2. Select the Status column in the new table.
  3. Click on Sort by column from the top ribbon.
  4. Select ID.
how to custom sort stacked bar chart in power bi

This way, we can sort columns with the help of another column.

Manage Relationships in Power BI

Now, I want to perform the relationship between two tables using the “Status” column:-

  1. Click on “Model view.”
  2. Click the Manage relationships from the top ribbon.
how to custom sort stacked bar chart in power bi
  • In the “Manage relationships” dialog box. Click the “New” button for new relationships.
  • In the “Create relationship” dialog box. Select the original table and Select the column you want to sort. In my case, it’s “Status”.
  • Make sure the “Cardinality” set Many to one. Then, the column has been mapped successfully.
  • Click on “OK”.
How to custom sort order in Power BI

In this way, we can Manage relationships in two tables in Power BI.

Create a Bar chart using the Lookup table in Power BI

Now, we create a bar chart with simple steps.

1. Under the Visualizations pane, click the Stacked bar chart. Then, in the Data panel, within the Custom List table, drag the Status column into the Y-axis. In the Project List table, drag the Project column into the X-axis.

Custom sort in bar chart In Power BI Desktop

You can create your custom sort order in the Power BI Bar chart.

Conclusion

I hope you have no doubt about custom sort in the Power BI Bar chart.

In this article, we learned how to create a custom table, manage the relationship between two tables, and change the order of a bar chart in Power BI.

Also, you may like some more Power BI tutorials: