How to change the order of bars in the Bar chart

When you assign a character column to the X-axis of a bar chart, the bars are sorted alphabetically by default. If you want to customize the order, you can convert the column to a factor and specify the order you prefer.

Let’s use a sales dataset as an example. Each row represents an order, and there’s a “Ship Mode” column that contains the shipping method:

  • Standard Class
  • Second Class
  • First Class
  • Same Day

By default, assigning this column to the X-axis of a bar chart will display the bars in alphabetical order, as shown below:

Suppose you want to display the bars in this specific order:

  • Same Day
  • First Class
  • Second Class
  • Standard Class

Here’s how you can do it:

1. Set a Custom Order for the Column

From the column header menu for “Ship Mode”, select “Set Order for Values” > “Manually”.

2. Specify the Desired Order

Enter the values in your preferred order:

"Same Day", "First Class", "Second Class", "Standard Class"

Click Run. This creates a new step, which appears on the right side of the window.

3. Create a New Chart with the Updated Column

Now, create a new bar chart and assign the “Ship Mode” column to the X-axis. The bars should now appear in the specified order.

If the order isn’t reflected, ensure the Chart Pin (at the top right of the chart view) points to the step you just created.