###### Recent Posts

###### Featured Posts

Side by Side bar charts are a very popular type of bar charts in which there are multiple bars attached to form a group and this group of multiple bars is repeated.

Â

This type of chart can be used in a variety of use cases, the most popular being comparing multiple measures with each other and also observing the change in those measures with time or across different categories. Despite of being popular, there is no way we can create this type of chart by just dragging the components in Tableau. But I would say it is fairly easy to make them, and that is what this post is going to focus on.

Â

Here is an example of Side by Side bar chart from the famous storytellingwithdata blog:

In the above figure, we are observing the Before and After Engagement categories across different dimensions on the X axis.

Â

Lets make an attempt to make our own Side By Side Bar Chart.

Lets say we want to visualize the average and median no of steps that we take and we want to see both for each day of the week. Here, the we have to make a group of 2 bars (average and median) across different dimensions (Day of the week)

Â

We start by dragging Day of the Week dimension to the Columns Shelf. Now if we drop both the median and the average measure to the rows shelf, Tableau makes two different bar charts for each of them as shown:

Â

But we want them to group together. Here's the trick to do so:

Take from the Dimensions, Measure Names pill and drop it in the Columns Shelf right after Day of the Week.

Now take Measure Values pill from the Measures and drop it into the Rows shelf.

This will create a two partitions of the x-axis instead of one, one for Day of the Week and other for Measure Names.

You may have noticed that a new card appears just below the marks card and its name is Measure Values. By dragging new measures to this card, we can actually increase the elements of the group.

Â

So that is how it is done. Here is the visual:

Â

But wait what! Do you think this looks like a group of bar charts!?

Nope, because actually there is no gap between groups and so elements of the next group start just next to the elements of the previous group. This defeats the purpose, as it gives us a continuous feel, not categorical.

Â

It turns out that to give it a categorical look, we need to add spaces between the elements of different groups. To add spaces, we can add empty elements at both the starting and ending of the group elements, And in order to add group elements, all we have to do is to add a measure to the Measure Values card as already explained.

Â

To add empty elements, we create a Calculated Field cal with just 0 inside it. And since we need to add spaces both in the start and in the end we make a copy of this Calculated Field: cal (copy). Add these two to the start and end of the Measure Values card.

Â

By doing this, the elements of different groups are still next to each other in the graph, but since we have a calculated field with value zero at both start and end, it looks like the groups are separated.

Â

Now, all we have to do is to edit the alias of the cal and the cal(copy) measures and change them to empty spaces so that they are not visible on the axis.

This gives a pretty good illusion that the groups are separated from each other, but actually there are 2 calculated fields between them with values 0.

Â

Here is the final look:

Â

Â

This is how we can make a Side-By-Side Bar chart in Tableau.

Â

Have any doubt or a better solution?

Let me know :)

Â

Kush.

Â