Different ways of sorting bar charts

In this week’s community post, we will see different ways of sorting in a bar chart.
For example : There is a table with info like Country, Sale Amount, Product name and other columns.

Let us plot a stacked bar chart categorized by product name. We can easily plot a bar chart with Country in x-axis and Sum of Sale Amount in y-axis and color categorized by Product name. By default, the chart would sort alphabetically by Country in the x-axis and by product name for the category

X-axis column sorting : We should note that x-axis column can also be sorted from the column dropdown based on Sum of Sale Amount or custom sorted based on any other columns in the table

Here is a screenshot how it appears when custom sorted by Count of Quantity

Category column Sorting : Similarly, category column could also be sorted based on Country or Sum of Sale Amount or Custom sorted based on any other column in the table

Quick way to see how the charts x-axis and category are sorted by clicking on the 3 dot menu of the element-> Sort

Here is a visual how it looks when x-axis and category column are sorted by Sum of Sale Amount in descending order

One most commonly asked question is to sort category column based on TopN filter. For this, we create a filter for the category column, ie Product name here and change the filter to Top N

When we want to see just the top 5 products, here is how it is after filtering by Top 5 products for each country

Here is a visual when we want to sort x- axis Top 2 countries based on the product selections from the category column

Similarly, we can sort on various combinations according to our requirement.

1 Like