Charts and Dashboards: A Bar Chart with Dynamic Ordering – Part 1
21 May 2021
Welcome back to this week’s Charts and Dashboards blog series. Over the next two weeks, we will discuss creating a bar chart with dynamic ordering.
Bar Charts are not only useful to illustrate the magnitude of values in one or more data series, but also a good alternative to the Pie Chart, which compares the proportion of a series in a group of data.
For example, here is enrolment data for six sport courses from a youth centre.
From the above data, if we create a bar chart, it may appear as below:
We want the bar chart to illustrate the percentage of each course’s participants relative to the total and also sort the bars in order from largest to smallest.
One way to sort the bars is to turn the data in cells F12:G18 to a table by highlighting the range and press CTRL + T, then sort the Participants column in the descending order. However, when we update the data in the table, we need to sort the data again so that the chart works in the way we want.
Let’s consider another way to get this working without using tables. In column H, we will get the order of the bar using the RANK function. The formula in cell H13 is:
Next, we will create a Chart Data section to get the related data in order. We will >INDEX MATCH against the Rank to get the Course and Participants. The formulae in cells G26, H26 and I26 are respectively:
There is one thing that is not quite right here. Suppose the data changes and the number of participants in the Swimming course and Yoga course are equal e.g. they are both 400. Their ranks will be equal first and the Chart Data will no longer be correct.
Hence, we will fix the formula in cell H13 to get the unique rank:
If we revert to the original data and now that we have the Chart Data ready, we will select the Course and % columns to create an initial bar chart that looks like the one below.
We can do more to get the chart a nicer look, but that’s for next time…
That’s it for this week. Come back in a fortnight for more Charts and Dashboards tips.