Online tableau training, tableau tips, & video tutorials

Tips

Memberships

How to Make Rounded Gauges in Tableau

Preview

Instructor

Ryan Sleeper

Improve engagement and design with rounded bars or gauges

Ryan shares a hack using calculated fields and a dual-axis combination chart that makes bars and gauges appear rounded. Rounded gauges make it easier to communicate the direction a gauge is “filling” up.

Hi, this is Ryan with Playfair Data TV. And in this video, I’m going to be sharing one of my favorite tricks, which is to round bars and gauges in Tableau. Just gives it a nice little design polish. And it requires a little bit of a hack so you don’t see this very often. And I think it just really enhances these traditional bars and gauges.

To get started over here in Tableau Desktop, we need three fields. One is the field that is drawing the bar. And then the other two are calculated fields. One creates the start of the gauge. And the second creates the end of the gauge. These rounded gauges tend to work best when we’re going from 0 to 1. So anything that goes from 0 to 100 percent, this will be a really effective chart type and little trick for you.

To create that first calculated field, I’m going to just click this down arrow in the top right corner of the Dimensions area and click Create Calculated Field. And this is the start of my gauge. And because we’re going from 0 to 1 or 0 to 100 percent, if you convert it to a percentage, the entire formula is the aggregation of minimum and then 0. So MIN 0 is the start of my gauge. Going to click OK.

And we need one more calculated field, which will be the end of the gauge. And again, it’s the aggregation of minimum. But this is the very right-hand side of my gauge. So it goes all the way up to 100 percent, which is the same thing as 1. So minimum 1 will create the end of my gauge. Going to click OK.

To create this view, we need to use the special generated field called Measure Values. I want this to be in a horizontal orientation. So I’m going to put my Measure Values onto the Columns Shelf. And we could do this with any dimension. We can break this down by any dimension. Just to give you one example, I’ll use a dimension from the sample data set called Shipping Mode. I’m going to put that onto the Rows Shelf. And I’ll make this a little bit bigger so we can see it by hovering near the bottom of the chart and dragging that down.

All right, so at this point, we’ve got all of our measure values in the sample data set, plus the two new calculated fields that we created– the start of the gauge and the end of the gauge. And these are all just kind of stacked on top of each other at the moment. First thing I want to do is get rid of all the fields that I don’t need. There’s two ways to do this. I can drag them off of this Measure Values Shelf. Or I can click into this filter and deselect the fields that I don’t need. Either way, both of these are going to work for us.

But I’m just going to deselect Discount, Number of Records, Profit, Profit Ratio, Quantity. And we’ll base these rounded gauges on the Sales measure. So we’ll pretend that that’s the measure that we were wanting to plot. So again– I mentioned this– we need three fields– the measure we’re wanting to plot, the start of the gauge, and the end of the gauge. So those are the three fields. I’ll click OK.

I also mentioned that this works best when you’re going from 0 to 1. So instead of showing these raw sales values, I’m going to add a table calculation to the Sales pill, which converts that from a raw sales value to its percent of total across the four different shipping modes. I’m purely doing this to show you an example, not necessarily the greatest example in the world. But this is going to work with any metric where you’re going from 0 percent to 100 percent.

To add this table calculation, I’m going to click onto the pill, hover over Quick Table Calculation, and choose Percent of Total. If you’re not familiar with those, by the way, there is a video here at Playfair Data TV to help explain a little bit about table calculations. Just do a search for An Introduction to Table Calculations in Tableau.

At this point, we see four bars. It looks like they’re all going to 100 percent, which they do, but there’s more there. It’s just the fields are kind of hidden on top of each other. In order to color these so that we can see them better, I’m going to drag the generated field called Measure Names from the Dimensions area of the Data pane to the Color Marks Card.

Now we can see some different colors coming together. One thing that I like to do when I’m creating these gauges is I like for the measure that I’m plotting and the beginning of the gauge to be the same color and then the rest of the gauge to be a different color. This gives it a visual effect that makes it look like it’s filling up.

So I’m going to modify these colors by double-clicking any of the colors in the legend. And for the measure that I’m plotting, maybe I’ll give this a nice, fun kind of bright color like a teal. And I’ll make the start of the gauge the same exact teal color. For the end of the gauge, I usually go with some type of gray. Because it, again, we’re trying to create this visual effect like it’s filling up. Gray is a good solid color for kind of being empty. So I’ll choose this light gray for the end of my gauge. And I’m going to click OK.

It’s starting to look a little bit better. Notice that all my teal bars are starting at the value of 1 on the x-axis. What’s happening is these marks are stacked on top of each other. The end of the gauge, that was a calculated field we set up which equaled MIN 1. So all those equal 1. And then we see the percent of total being stacked on top of that number 1.

Well, we need to turn these stacked marks off so that they’re laying right on top of each other. And you can do that by going to Analysis in the top navigation, hovering over Stack Marks, and clicking Off. Now this is really starting to come together. And in fact, at this point, we have a gauge that’s filling up. The teal color is the percent of sales for each shipping mode. And then in the background, everything else is colored gray. That’s the rest of the gauge that’s empty. That’s why these all go to 1.

So this would be an OK place to stop. However, I really like to round these because I believe it better entails that you’re trying to show something filling up. It’s better at showing direction. These rounded gauges or rounded bars, sometimes they get a bad rap because they– you lose a little bit of precision. When you round the edges, we can’t see that this ends at exactly 0.59.

But on the other side and the advantage to it– there’s always two sides to these stories, and a lot of this is subjective– one of the advantages to circling the marks is it kind of better shows the direction that the gauge is filling up. So that’s what we’re going to do now.

To create the rounded appearances, I need to duplicate the Measure Values pill. You can do that by holding down the Control key and dragging Measure Values right next to itself. So at this point, we’ve got the same gauges, if you will, in two different columns. But when we duplicated the Measure Values pill, we get a second Marks Shelf that can be edited independently of the first. So the first column, we can leave as is. But on the second column, we can change the mark type to Circle.

So far so good. I’m now going to combine these two columns into a dual-axis combination chart. It’s called a dual-axis combination chart because we’ll have two axes with a combination of mark types. Again, if you’re not familiar with this functionality, there’s another video here at Playfair Data TV. Just look up 3 Creative Ways to Use Dual-Axis Combination Charts. It’ll give you more explanation. But this is yet another application of using a dual-axis combination chart. This is a very powerful functionality that unlocks a lot of cool formatting tricks in Tableau.

To create or convert what we’ve got into a dual-axis combination chart, most people learn this as clicking on the second pill. And the third option down is Dual Axis. That’s probably the easiest way to do it. If I do that, it makes my marks lay right on top of each other. Tableau actually tried to help me out here a little bit by converting one of the mark types back to Circle. I actually still wanted that to be Bar. So instead of Circle, I’ll change that back to Bar. And you’ll start to see this coming together.

One thing with dual-axis combination charts is you, if you’re using the same scale on both axes, you’ll want to ensure that the axes are synchronized. Very easy to do this. Just right-click on either axis and click Synchronize Axis. You saw just a tiny shift there. You also saw the circle that’s lining up with the 1 value on the x-axis come into view. We couldn’t see that before because the axes weren’t quite lined up. So that gray circle was a little bit further down to the left. And we couldn’t see it.

This is also a good example to show you where we lost a little bit of precision. Notice the circle for 1 is right on the 1 on the x-axis. But because it’s a circle, it doesn’t have a sharp edge. It kind of protrudes a little bit further out there. It looks like it almost goes to 1.03 percent. So that is the drawback, I admit. You lose a little bit of precision. But if you’re trying to design something and make it user friendly, you don’t always need those exact precise numbers. To me, knowing that this is about 1 is good enough. You do lose the ability to see that it’s actually 1.03, for example. But this is really close.

The last thing to do at this point is just to resize these marks so that it appears it’s one cohesive gauge. It looks like my bars are too big. So I’ll click on the Size Marks Card. And drag this over to the left a little bit. Wow, first try. That’s never happened. So I drag that over on the Size Marks Card. And I went to that tick mark right in the middle.

I’m laughing because this can be a little bit touchy. You’ll just have to kind of experiment and go back and forth between the Size Marks Cards on your bars and your circles. But the goal is to line those up as closely as possible so that it looks like a cohesive gauge that’s filling up from left to right.

Couple last little formatting things. It’s good practice to sort these. So I’ll go ahead and click this Sort Descending button underneath Window in the top navigation. And now that we’ve got this working, we don’t need both of the axes. So I will hide one of them by right-clicking and deselecting Show Header. And there you have it. This is a rounded gauge that’s filling up from 0 to 100 percent in Tableau.

This has been Ryan with Playfair Data TV – thanks for watching!