My Second Tableau

Bill Comeau
17 min readMar 8, 2019

Tutorial #2: Building Skills and Enhancing a Hockey Bar Chart
Prerequisite: Tutorial #1 “My First Tableau”
Viewable and downloadable Tableau workbooks created from doing the tutorials can be found at: bit.ly/Billius27

Disclaimer: I am not a professional data visualization expert nor do I work in the field, the suggestions I make are based on my own Tableau Public experience using my personal “learn as I need to learn” approach and without formal training. There are a variety of ways to “make things happen” in Tableau, I have chosen dropdown menus where possible for screenshot simplicity, in practice I avoid my keyboard as much as possible but that’s up to each user. Readers are welcome to share tips, shortcuts or corrections in the comments.

In ‘My First Tableau’ we created a raw bar chart derived from the amazing public hockey data provided by NaturalStatTrick.com. It showed the Points per 60 minutes of playing time for Colorado Avalanche NHL hockey players. In this second tutorial we want to cover more intermediate functionality that will allow us to :

  • clean and modify our data,
  • enhance our interactive filters,
  • expand our understanding and use of the Marks Card options,
  • spiff up the look of our viz
  • introduce dashboards

I find these steps are usually the natural order for me, I like to progress from raw data to cleaned and subsetted data and then worry about the more cosmetic final details at the end.

When we are done, our enhanced bar chart will let us explore well beyond Total Points/60 and give us a much more publishable viz.

Here’s where we left off last time. Warning: enjoy the blue on white while it lasts.

Let’s start by clicking the title area and changing the title to something entirely original like “My Second Tableau”. Then let’s use the “Save it to Tableau Public” option under the main File menu to save it online as “My Second Tableau”. (We don’t want to overwrite our first tutorial viz.)

1. Cleaning and Modifying Data

This tutorial assumes you have already completed the steps in the first tutorial, including installation of Tableau Public and import of a csv hockey data file from NaturalStatTrick.

Tableau divides the data into two categories: dimensions and measures. Dimension fields are mostly used for row or column headings; measures are usually used for plotting or giving values to the sizes of markers (like bars).

Sometimes you will need to change a measure to a dimension or vice versa. To do so, simply drag the item under the appropriate heading on the left side. Notice that dimensions are blue and measures are green. Each field is assigned a data type when it is imported, you can see the “#” and “abc” labels on the left for numeric and string data types.

There are limits to what you can do in Tableau to clean and modify data once it is imported. For example, you cannot create a new measure with new data values. Tableau assumes you have done the basic prep work before importing your data. But there are important things that you can do.

Hiding Fields

Sometimes we import measures or dimensions that we don’t want to use in Tableau. F1 is an example. Let’s hide it so it doesn’t clutter up our work. Then let’s do the same for Number of Records.

Changing Data Type

When Tableau imported our data, it wrongly assumed that Faceoffs % was a string (alphabetical) measure. Let’s change it to Number (decimal) from string and also change the Default Properties > Aggregation to “Sum” instead of “Count (Distinct)”.
Let’s also go through the same process for IPP further down the measures list.

Creating Calculated Fields

To create a new field, we can start with an original field like Penalties Drawn/60 and select Create > Calculated Field as shown. A pop up window lets us name the new field and insert a formula.

Now we are ready to calculate a Penalty Differential/60. More on Calculated Fields can be found here.

Creating Grouped Fields

Right now the Position dimension contains NHL values for a player’s position. Unfortunately, many of the forward values are out of date or wrong. To streamline it and make it more useful, we want to collapse all forward positions into one category.

To do this, we select Create > Group and then use the pop up options to organize the values into two Groups as shown.

This is how I often simplify the filters I use in my hockey viz.

2.0 Filters

Filters are a key interactive tool and we want to make sure that they provide enough options so that users can focus in on the subset of players they want to see. We also want to make sure that they are intuitive.

We already added Team and Position as filters in the first tutorial.

So we first need to remove the current Position filter and replace it with our new Position (group) field. To do this, we first go to the Filters box, select Position and then select “Remove” from the drop down menu. Now we click Position (group) and select “Show Filter” from the menu.

Now let’s change the way the filter works — go to the filter on the right and select “Single Value (list)”. This option makes sense because the list is short enough to not overwhelm the viz and users just need to click a button. At the same time, we can can edit the title from the same menu, so let’s change it to “Position”. It should now look like this:

Now we could create a grouped field for Team as well to collapse traded players into their new teams but let’s leave them in case users want to see them separately (plus it’s a lot of manual work). But because the default filter display is a very long and cumbersome list, we are going to change it to “Multiple Values (dropdown).

We chose Multiple Values here so users can decide which traded players they want to include with the core team. We could add Derick Brassard to our Colorado Team by also checking the box for his trade from Florida in the Team Filter. (One other option is to add a “Player” Filter if you are interested in league-wide selections of players.)

A slide filter for minimum TOI

Next, let’s add a TOI filter by going to TOI and ‘Show Filter”. It’s useful anytime we are showing player stats but especially when we are looking at per 60 or per game rates. Our Colorado viz has Dominic Toninato leading the Avs but that’s a bit misleading because he only played 13 minutes. I modified this one using the drop down menu — I edited the title and selected the “At Least” slide option so the user only needs to be concerned about setting a minimum. I also set it to 100 minutes as a default. Stats can still be unstable below 500 minutes but often we want to see how players are doing earlier than that.

Creating a Multiple Measure Filter

This one greatly expands the usefulness of our viz. Instead of having a chart that focuses on one stat like Total Points/60 we will let the user decide which measure they want to look at in the bar chart. This is where the power of an interactive Tableau really comes into play.

First, let’s go down to the bottom of the Measures list and drag the “Measure Values” green pill up to the Columns shelf and drop it on top of the Total Points/60 green pill. It should replace the old pill but if not, just remove the Total Points/60 pill.

Now your viz should look like a complete mess. That’s ok.

Let’s use the drop down for the Measure Values pill and select “Show Filter”. It won’t have “All” checked so check All, then use the Filter dropdown menu to select “Single Value (dropdown)” for our Filter and set the Filter to “Total Points/60”. Now our viz should look like it did before.

Except now we can select whichever measure we want. This is good.

Change the Color and Text pills to Measure Values

We will need to make some adjustments now that we are using a Measures Filter. First, remove the two Total Points/60 green pills for Color and Text from the Marks Card (you can either drag them outside the viz frame or use the dropdown menu for each one).

Then just drag the Measure Values pill twice — once to the Color card and once to the Label card.

Now the gradations in colour and bar label will match the Measure we select in our filter.

We need to make a few more steps to get this filter working at its best.

Unfortunately, there is no easy way to allow sorting by the measure we select. (Parameters can do this but are too advanced for this tutorial.) So the best default will be sorting players alphabetically — just use the dropdown menu for Measure Values in the Columns shelf and change the Sort to alphabetical.

There are 32 measures in the drop down and some are not of general interest unless you’re really into the details of penalties and other less-used measures. To handle this, we can use what we learned about Hide earlier and Hide the measures we want to remove from our dropdown. (Hide can always be reversed later by using Unhide.)

To illustrate, I will Hide half of the 32 measures and leave 16, you can choose your own custom measures if you wish. I’m also going to make the order of the Measure Names more intuitive by going to Measure Names in the Dimension area and using its dropdown menu to select Default Properties > Sort and choosing the Manual sort option.

Finally, we need to remove the “All” option from the Filter list and modify the title. To do this, use the dropdown menu for the Measure Names Filter on the right side and choose Customize, then unclick the “Show All Value” option. Edit Title is on the same menu, we’ll change it to “Statistic”.

With these changes, the Filter should now look like the one on the right.

Now we can test out our filters. Staying with Colorado, let’s check out defensemen with 100+ minutes Time On Ice and look at their TOI/Game Played. Our worksheet should look like this.

Let’s go to the Marks Card now and make a few more refinements.

3.0 Using the Marks Card

The Filter Card and Marks Card are really the two main drivers in Tableau, one helps make the data interactive, the other helps make the data visual.

Without really knowing it, we’ve being using the Marks selector menu— Tableau automatically chose bars as the “marks” given the data we moved to the column and row shelves. (You can see from the list above that there are many choices. If you take a side trip over to the “Show Me” menu in the upper right, you will also see many chart options with the required row and columns pills.)

Tableau also automatically chose a standard sizing for the bars and a Blue palette when we moved the Measure Values pill over top of the Color box. And when we moved Measure Values over the Label box, it chose a default way to display the labels. It also automatically set a default Tooltip when it saw the pills we were using on the shelves. The Detail box picked up on Measure Names as well.

You can check each one out by clicking on it and seeing the option it selected.

Now I am going to briefly walk through how you can change these — it’s pretty intuitive once you start working with these Marks boxes.

Size, Label, and ToolTip automatic settings

Just for fun, try moving the TOI/Gp measure over the Size box. Notice how players with less TOI/Gp have skinnier bars now and a size legend is added on the right side? It’s an option but we won’t use it today.

Just for testing, reset the Position Filter to All and try dropping the grouped Position pill over the Color box and the TOI/Gp over the Size box. Then use Edit Colors and set Defensemen to red and Forwards to green.

Your viz for Colorado should look something like this:

Notice how the Marks chosen are automatically displayed under the Marks boxes on the left and legends are provided on the right. There are many directions you can go but remember that every feature added and highlighted visually adds complexity which is not always good. You want the viewer to interact but you also want it to be intuitive and understandable within a few seconds.

Secondary marks may also have less visual meaning in terms of exact values, a graduated color or bar width will have a fuzzier meaning than an exact bar length with a scale. The choices made are partly logical and partly design art. There are many articles on the subject if you are interested, including Tableau resources.

Always ask what the main purpose of your viz is. You should be able to write it down in one sentence, such as

I want to quickly and easily see how an NHL team’s players are doing this season relative to each other on 16 different per 60 stats, with the option to drill down by position, set minimum ice time, and see details in the Tooltip.

Based on that ‘mission’, I don’t think we need to add the complexity of skinny bars or even different colors by position. In fact, we don’t really need to clutter the bars with labels that show decimal places etc. The values could be in a Tooltip if needed or we could use fewer decimal places. It’s a toss-up but I’ll keep the modified labels for this tutorial. Sometimes you will want a cleaner look but in this case it’s good to remind the viewer what stat they are looking at and the values it takes (ie not points but points/60).

Let’s remove those color and size test pills (you can just use the back arrow or physically remove the pills) and at the same time let’s take a look at the bar labels.

The easiest way to remove the labels is to just uncheck the box at the top of the Label menu.

It’s not an easy decision sometimes, so there are lots of options here. You can change what you display (Text), what Font you use, where they appear on the bar (alignment), and which to show (Marks to Label).

This would be a good time for you to play around with those.

One option you don’t see is an option to change the number of decimal places. That falls under formatting and since the label is Measure Values, we can reformat it by going to Measure Values, selecting Format from the dropdown menu, then choosing Pane > Numbers > Numbers (Custom) > Decimal places. We have to compromise a little here because the formatting will apply to all measures.

The Tooltip could use a couple of additions, so let’s add the Team and TOI pills onto the Tooltip box. This should place them into the Toolip, if not you can use Insert and editing to modify the Tooltip (left). The Tooltip itself should pop up when you hover over a part of the viz (right).

Tooltip edit screen (left) and example (right)

That’s it for the Marks Card in this tutorial, you can read more here.

4.0 Formatting the Display

I had to think about how much to show in this tutorial and opted to give a final formatting section that would include a taste of dashboards even though a dashboard isn’t really needed for a single bar chart. I also had to decide on a color theme and opted to use my favorite theme — BLACK.

I would not disagree with anyone who prefers a white or more neutral background for clarity, color blindness viewing, or other reasons. But you can’t teach old dogs new tricks and I just like a black background, so prepare to suffer. This process can easily be modified to other color themes. Reading articles like this one should also provide more perspective. Whatever you decide, add in a sprinkle of uniqueness because there are a gazillion white background documents already floating around in the world.

Sample Viz from my Tableau Gallery

Let’s get started.

There’s a window at the top that says “Standard”, I prefer Entire View for this viz, let’s change it. There’s also an icon at the top that lets you swap rows and columns. Make your choice now. I prefer keeping words the way I normally read them but you can make the bars vertical, doesn’t matter.

The WorkSheet title can be refined. I chose to insert “ Team” and “Measure Names” along with a Tableau Medium 15 font. The Insert option lets the title change dynamically with those filter choices, which is sort of cool.

Title edit window with dynamic field names (left) and example (right)

One way we can call up the format sidebar window is to just right click on the main viz window, or you can use the top menu. Our worksheet screen should look like this now with the most recent changes.

I start with the shading, shown as a bucket, and make the worksheet default black then I go to the “A” for Font and change it to white. I then work with the grid lines, in this case I am changing the column lines to be thin and 25% opaque. Sometimes you will want to push one or more elements into the foreground or background and might choose a greyer or bolder color. In this case I opted to still show vertical lines but to have them loss obvious and I kept the player names and such at full white. You can tinker with these to get a scheme you like that emphasizes what you want.

Remember we left the worksheet title in a black font? Now we should go back and change it to white by clicking open the edit title window again and selecting white.

The labels on the bars are waving at me so let’s soften them, they draw too much attention. We can go back and format Measure Values again using the drop down and choose a more neutral grey against the black background.

The Filters and Legend also need formatting. Using the Filter dropdown menu for any Filter, we can reformat them all by choosing “Format Filters” and setting the Body Shading to black. Repeat the process for the Color Legend.

The horizontal axis has too much going on and stands out too much. Because the measures vary, we can’t edit the axis and fix the number of tick marks easily, so I just went in and clicked the axis and chose Format to soften the values to a less obtrusive grey. At the same time I added a reference line in the same menu and chose a thin white dashed line as a reference, with no label (should be obvious it’s an average).

Needless to say, we’re just scratching the surface of some of these features.
Our worksheet should look like this, unless you mutinied along the way and changed my GothPaintItBlack™ color scheme. I see you. 👀

If you use the Presentation Option on the top menu, you should see something like this now. Notice that the filters on the right side still have ugly white titles, even though we formatted them. This will get fixed in the next step.

The final worksheet

5.0 Introduction to Dashboards

This will just be a teaser, just enough to show how to embed a worksheet into a Dashboard and add a main title and text caption. At the top menu, click Dashboard and select New.

Then drag Sheet 1 into the drop area. Now click the Show Dashboard Title in the lower left.

Initial Dashboard screen

Now open the Size dropdown menu on the left side. Set the maximum width to 950 (or whatever you like).

Under the Dashboard Menu at the top, select Format. Then set the Dashboard shading to black.

You can also now set the Dashboard title font to Tableau Semibold 24 (White) and change the title to “My Second Tableau” or whatever you like.

Let’s drag and drop the Filters in the order we think users would find logical then we can go to the lower left and select a Tiled Text object to drag underneath the bar chart.

That’s a good place to add credits and details to help the viewer understand what data they are looking at.

Congratulations, you’ve finished Tutorial #2 in the “My First Tableau” series!

You’ve gained a better understanding of how to manipulate the raw data, how to expand interactive options, how to exploit the visual capabilities in the Marks Card, and more advanced ways to format for visual impact.

My Second Tableau

Where to next?
This is but one path through Tableau, there are many others — different chart types, measures, color palettes, a top menu and short cut commands that were mostly skipped, and a host of options still unexplored inside the Marks Card and Dashboard functionality.

If you liked the idea of having multiple measure choices, I encourage you to look into parameters which are a little more advanced. One of the main advantages of Dashboards is the ability to add multiple worksheets and that is a good area to explore. Of course, bar charts are only one type of viz, I encourage you to investigate the “Show Me” chart examples and try them out.

I hope you found this hockey viz tutorial helpful and look forward to seeing your own customized version of “My Second Tableau”. Don’t forget to save your work to Tableau Public online before closing your Tableau.

Bill Comeau, March 8, 2019

--

--

Bill Comeau

M. Math (Stats) (U of Waterloo) retired. Covid-19 analysis.