Ryan demonstrates why creating rounded bar charts will add professional polish, credibility, and ultimately improve the adoption of your visual analytics tool in Tableau. Additionally, this video tutorial walks through the step-by-step instructions to create a dynamic axis for the direct labeling of rounded bar charts in Tableau.
Hi, this is Ryan with Playfair Data TV. In this video, I’m going to show you the easiest way possible to make rounded bar charts in Tableau. I’ve shown you on a separate video how to make rounded bars and gauges when you’re trying to show how much of a gauge is filling up to 100%. But if you’d rather just look at one measure and one dimension, there’s a much easier way. I’m also going to show you a trick to make your axis dynamic, which will help with the direct labeling of bar charts in Tableau. And by the end of the video, you’ll be able to make something similar to what you see on the screen here, where you see the ends of those bars are rounded. And then you’ve got the direct labels nicely right aligned on the ends of each bar, each dimension member.
In my opinion, rounded bar charts are much more engaging, which will improve the likelihood that they’re adopted. It just adds a little bit of professional polish, improves the chances of somebody stopping and engaging with it. I also believe that it adds a little bit of credibility when something looks a little more polished. If more people are adopting it and looking at it, hopefully that lends itself to improved action in the organization, which is what we’re trying to cause. So let’s get started over here in Tableau Desktop.
Rounded bar charts, of course, can be created with any measure and any dimension. But so that you can follow along, I’ll be using the Sample Superstore data set. And maybe I’ll just use the Sub-Category dimension for this example. So I will drag Sub-Category to the Rows shelf. And this is the first trick with rounded bar charts. You don’t actually drag the measure of interest to the Column shelf. Instead, you drag that generated field called Measure Values. Generated fields are indicated with italic lettering. These come with every single data set that you use. We’re using the sample data set. So if I drag Measure Values to the Column shelf, I will see a new shelf up here containing all of the measures, these right here, that come with the Sample Superstore data set.
The trick to rounding the ends of these bars is yet another application of what I call the placeholder field. I always make my placeholder field with the formula MIN(0) So that’s the aggregation M-I-N and then I wrap it in zero. There’s lots of applications of this. That’s why I mention it. You’ve probably come across this on a different video at Playfair Data TV. Here we are again. We need to put a placeholder field in here, which will create the base of our rounded bar chart.
You could create a calculated field for MIN(0) But you can often apply it in the flow of the analysis, which I will do here by just double clicking on the Measure Value shelf and typing in that formula. M-I-N, open parentheses, the number zero, close parentheses, and hit Enter. When I did that, we saw a couple things change. We see some borders appear. What this is doing currently is stacking all of our measures on top of each other. We see a new measure appear on the Measure Value shelf. And we also see a Measure Names filter appear on the Filter shelf.
From here, we need to remove all of the fields except for the measure of interest and that newly created MIN(0) placeholder field. There’s a couple ways to do that. I could either drag the measures off of the Measure Value shelf or I can edit this filter on the Filter shelf and just deselect what I don’t want. Let’s say for this example that we want to look at Sum of Sales by Sub-Category. So I will remove everything except for Sales, which I can see over here is being aggregated as Sum of Sales in my MIN(0) field, and click OK.
I will also make these bars a little bit bigger by changing the fit of the view. And it’s typically best practice to sort bars in either ascending or descending order so that you can compare not only the lengths of the bars but the rank order from top to bottom. So I will sort these in descending order. The trick to rounding the ends of those bars is to change the Mark type from Automatic, which is currently set to bar, to Line. And this will create two different lines.
What it’s doing is connecting the dots by the Sub-Category dimension members. So we’ve got one line for each of our measures. We’ve got zero on the baseline just connecting it from top to bottom, and then we’ve got this line that’s not really providing any value, but it’s just connecting the values of where each bar was by Sub-Category from top to bottom.
The easiest way possible to change the direction in which Tableau is connecting those dots is to move the Measure Names dimension which is currently on the Detail property of the Marks card over to the Path property of the Marks card. When you do that, it changes the direction and connects the dots by the values from zero to the end of each bar in this case. And we technically already have rounded bars. They’re are a little bit hard to see. But if I bump up the size by clicking on the Size property, dragging that over to the right, you see that we’ve got these nice rounded bars going.
From here, the next thing I might want to do is directly label my bar chart. And what that means is just putting the label at the end of each bar so that the user doesn’t have to look back and forth at the axis. I find that this often looks a little bit nicer. It also provides the exact number, which a lot of my stakeholders are looking for. So I’m a big fan of direct labeling bar charts, particularly when there’s a relatively small amount of dimension members. In the Sample Superstore data set, we have 17 sub-categories. That’s kind of pushing it. But let’s go ahead and directly label the ends of these bars.
The easiest way to do that is to click on the Label property of the Marks card and just check this box, Show Mark Labels. OK, couple things I want to point out here. When we did that, we see zeros appear as well as the Sum of Sales on the ends of the bars. But there is an option on the Label property to click Line Ins and only show either the start of the line or the end of the line. If I deselect End of Line, the zeros go away. So just to point that out in this kind of tricky way to make rounded bar charts, Tableau’s considering the ends of the bars the start of the line and the zeros, which are the baseline, the end of the line.
That was an easy way to get rid of those. But if you were using a measure that had negative values, such as Profit in the Sample Superstore data set, that zero could be at the end of the line or the start of the line. And I just wanted to show you an alternative on how to get rid of that. So I will add those back and close that. If you’d prefer that these never show up, regardless of where zero is, you could just draw a box around them. Just be careful not to pull in any of the actual sales values.
But once you draw that box, if you right click on any of those marks that you’ve selected, then hover over Mark Label, there’s an option to never show those zeros. So that’s looking much better. The next thing I might want to do is convert those labels to show a currency. So I’d like to see a dollar sign on those sales values. So I will right click on Sum of Sales and choose Format, use this numbers drop down to choose Currency Custom, and maybe I’ll bump this down to zero decimals. So that’s looking better.
But here’s where I might run into trouble. And this is where the next trick that I wanted to show you comes in. Let’s say that we wanted to make those labels a little bit bigger. So I’ll bump up the font size to 12. Well when I do that, notice that my nice right alignment went away. This is a consequence of the Mark type that we’re choosing. Tableau handles labels on a Mark type of Line slightly differently than it handles labels on a Mark type of Bar.
Luckily, there’s a trick for this as well. It’s what I’m going to show you next. What we need to do is push the axis out far enough so that these labels are again, right aligned. We could edit the axis and change the axis range. But the issue with that is the axis becomes fixed. So let’s say we filter it later on. We’re still going to have the same axis range regardless of the maximum value on the view. To make that axis dynamic, we can set up a calculated field, which I’ll call dynamic axis.
And we’re going to use a window calculation to look up the highest value in the view. So this will be dynamic, even if it’s filtered. And the formula will be WINDOW underscore MAX open parentheses. What comes next is the measure of interest, including its aggregation. In this case, we’re looking at Sum of Sales. And I’ll close parentheses, close parentheses. So so far, what this calculation is going to do is look up the highest value in this window of numbers. We’re then going to multiply that number by some percentage to add to it, so to add to the maximum.
This number is kind of arbitrary. I admit, you kind of have the guess and check to see how far you have to push the axis out to get the label to appear, or to make it right aligned again. But let’s start with 1.10, which would represent a 10% addition. So times 1.10, that multiplies the maximum value in the window by 1. And then it’s the 0.10 that adds an additional 10% to the highest value in the window. I will click OK. See a new calculated field appear.
We also need to add that calculated field as a reference line on the view. To use a value within a reference line, it has to be on the view somewhere. Dynamic Axis is nowhere yet. But if I add it to the Detail property of the Marks card, that adds it to the view without changing the visual at all, or the analysis. So it looks exactly the same. But now that that’s on Detail, it will be available to me when I go to add a reference line.
There’s two places to add a reference line. You can use the Analytics pane on the left. Or my preference is to right click on the axis that I’m going to add the reference line to and choose Add Reference Line. Because I added Dynamic Axis to Detail, it will be available to me in this dropdown. By default, reference lines are showing whatever is on the axis that you are adding it to. So in this case, Measure Values. But if I use this dropdown and change it to Dynamic Axis, you’ll see the line up here, you’ll see that the labels were already fixed. They’re now nicely right aligned again.
So this is exactly what I was hoping for. But to clean this up a little bit, we’re going to get rid of that line or hide it to the extent possible. There’s a couple of options within this reference line dialogue to do that. First of all, we don’t need this label at all. It really doesn’t mean anything to my user. So I’ll click this label dropdown and choose None, the label goes away. We also don’t need that line at all. So a little bit further down under Formatting, there is a line drop down. If I click that and choose None, the line also goes away.
And it looks like we could have used maybe 5%. So multiply the max times 1.05. You can kind of experiment with that and get the exact amount of padding that you want. But I encourage you to go far enough so that you can see the entire label nicely right aligned. One more tip. If you ever have values that are negative, so let’s say you did use Profit and you’ve got the same issue where you’ve got negative bars that are going left and they’re not left aligned in that case or up next to the bar, because there’s not enough room to show them, you would have to make one more reference line.
And in that case, you would be looking up the WINDOW underscore MIN value. That would create the smallest value. Then you’d multiply that by 0.105 or 0.110 in this case, which would push it further to the left. And then you’d add it as a reference line, a second reference line.
But that’s the easiest way possible to make rounded bar charts in Tableau. This has been Ryan with Playfair Data TV. Thanks for watching.