Online tableau training, tableau tips, & video tutorials
Exercise: Bar Chart with Tableau Marks CardsPreview
AVG Profit by Region
In this self-guided exercise, you will improve the first bar chart by adding analytical context through the use of the Marks Shelf and Marks Cards.
Hi, this is Ryan with Playfair DataTV, and in this exercise we’re going to build on to the bar chart that we made in the last exercise that looked like this. So we’re looking at average profit on the rows shelf and breaking it down by the dimension called region on the columns shelf.
We’re going to add to that using some of the lessons that we just covered to take it to the next level. We’re going to do a couple of things here. We’re going to, in addition to having the length of the bars represent average profit, we’re also going to color the bars by average profit. So you have to put something on the color marks card. We’re also going to customize the labels. There’s two things on the label marks card. There is the dimension of region as well as the measure of average profit.
And then the last thing is we’re going to not double encode the y-axis. We’re going to do a direct label. Now that we’ve added the labels directly to the marks, we no longer need the y-axis, so we’re going to hide that. Pause the video, and I’ll come back and I’ll recreate this in just a moment.
All right. To match this view and build on to the bar chart that we had already made, average profit by region, the order doesn’t matter too much. Actually, it doesn’t matter at all. You’ll get your own habits and how you’d like to do this. But the first thing we need to do is color the bars by average profit.
There’s two ways we can do this– actually, three. Again, always more than one way to do the same thing in Tableau. The first way you might think to do this is to right-click on the profit measure and drag it to the color marks card. Because we right-clicked, Tableau is going to allow us to choose the aggregation of the measure before it adds anything to the view. So we could choose average profit, click OK, and you can see here in the top right corner, the bars are now being colored by the average profit.
If you forgot that shortcut to hold the right mouse key while you’re bringing the profit onto the color marks card, I want to show you you can also change the aggregation for a measure that’s already on the view. So if you just clicked profit, dragged it to color, it would be coloring the bars by sum of profit, but not average profit. So there would be one more step. You’d have to click into that measure, hover over measure sum, and change it to average.
There is a slightly more efficient way to get the average profit onto the color marks card. This is my favorite shortcut in all of Tableau. I’m going to first of all remove what’s there for now. If you hold down the Control key while you click a pill, so a field that’s already been added to the view, it creates a duplicate copy of that pill. Lots of applications for this.
For this first one I’m going to show you, if you hold down the Control key and click Average Profit that’s already on the view, left-click, and drag it to color while I’m still holding down Control and then let go, it created a copy of that pill. So average profit is now on the rows shelf, it’s been copied, and it’s also on the color marks card. So we save that step of having to choose the aggregation. We guaranteed that the aggregation was the same thing on the color as well as on the rows shelf.
The next thing we’re going to do is customize the labels. We’ve got both region and average profit on label. So I’m going to drag those two fields to the label marks card. I’m going to drag Region to label, and I’m also going to drag Average Profit to label. Same options as we had when we dragged average profit to color. You could either hold down the right mouse key and drag Profit to label, choose the aggregation of average. You could bring sum of Profit to label, and then change the aggregation by clicking into it, hovering over measure sum, choosing average. Or you could hold down the Control key, click Average Profit that’s already on the view, drag it to label. Three ways to do it.
Notice, though, that the default formatting isn’t quite the same. It’s in decimals and there’s no dollar signs. If we want to change that, just think out loud of what you’re trying to modify. We’re trying to modify the format of the label for the average profit measure. So if in doubt, right-click– I’m going to right-click on the average profit measure. The third option is a hint format.
We can change the formatting of the numbers on the axis or the pane. In this case, these numbers on the labels are considered to be on the pane, so we’re in the right spot. We’re on the right tab. And I’m just going to use this third drop down for numbers to change the default formatting to currency custom with zero decimal places.
So really close. Last thing is because we’re direct labeling, we no longer need that y-axis. This is actually another case of double encoding. There is another topic in data visualization called maximizing the data-ink ratio. That’s a term coined by Edward Tufte. He’s kind of a modern data viz pioneer. And in his 1983 book, he coined this term data-ink ratio. That has to do with the ratio of the total amount of ink on the view, so that any text or any time you see anything that’s considered ink, and how much of that ink is dedicated to data.
So the ratio is data-ink divided by total ink. That gets you your data-ink ratio. And you’re always trying to maximize that ratio. And there’s also something called redundant data-ink. So while this y-axis is related to data, so it’s considered data-ink, it’s quite redundant. All the values start at the 15 tick mark here on the y-axis. So we don’t really need five and 10. We also don’t necessarily need increments of five. Maybe we want to make those increments of 10. So some of that data-ink is redundant.
And now that we’ve already got those values directly labeled, I would prefer just to hide that axis. Again, if in doubt, right-click, so if I right-click on the y-axis, the hint that I’m looking for here is called Show Header. If I deselect that, you will match the bar chart shown to start the exercise.
This has been Ryan with Playfair Data TV – thanks for watching!
Related video: 5 Ways to Make a Bar Chart and An Introduction to Aggregation
Related video: An Introduction to the Tableau Marks Shelf / Marks Cards
Related chapter: Practical Tableau – Chapter 10 – Marks Cards, Encoding, and Level of Detail
- Cornerstone Module (Part 1)
- Tableau’s Product Ecosystem
- Shaping Data for Use with Tableau
- Connecting to Data in Tableau
- Tableau Classification: Measure vs. Dimension
- Tableau Classification: Discrete vs. Continuous
- Getting a Lay of the Land in Tableau
- 5 Things I Do When Working with Data for the First Time
- 5 Ways to Make a Bar Chart in Tableau and An Introduction to Aggregation
- When in Doubt in Tableau Then Right-Click
- Exercise: Make a Bar Chart in Tableau
- An Introduction to the Tableau Marks Shelf / Marks Cards
- Exercise: Bar Chart with Tableau Marks Cards
- Tableau’s Detail Marks Card and Visualization Level of Detail
- How to Make a Line Graph in Tableau
- Exercise: Make a Line Graph with Continuous Quarters in Tableau