Monday, 9 February 2015

How to do football analysis in Tableau | Part 3

If you've been working through these posts, so far you've copied some football data from a website into Excel, cleaned it up and learned to build simple tables and charts with that data on a Tableau worksheet.

In Part 3, we're going to create our first interactive dashboard.  We'll make a dashboard that lets you select a team and then it will show you which are that team's strongest players.

If you had fun messing about with Tableau in Part 2 and learning by building loads of different views (I really hope you did. Screw instruction manuals. Including this one), then you might want to start a brand new Tableau workbook at this stage and connect to your Excel data again. Have a look at the early bits of Part 2 if you can't remember how that worked.

Make a new worksheet and drag Mins, PS%, Assists and Goals into the view, then split the rows by Player Name and Position. You're looking for a view like this.

PS% is a downright unhelpful name for Pass Completion %, so right click it in the Measures Area (bottom left of the screen, remember?) and rename it. Tableau will then automatically change the name wherever else you've already used it.

It might be good at this point to also change Pass Completion from Sum to Average. It doesn't really matter, because you've told Tableau to split the data by player and there's only one row of raw data for each player, so Sum and Average are the same. If you'd split by team instead though, and then summed pass completion, the data wouldn't make any sense because Tableau would add all of each team's players' pass completion rates together.

Right click the little green lozenge for Pass Completion % and change it from sum to average. If you really want to see the difference that makes, take the Player Name split out of the view for a moment and try Sum and then Average.

It always helps when you're using Tableau, to keep in mind what your underlying dataset looks like, otherwise sum and average (and as you get more advanced, weighted averages) can get you into trouble.

Back to the table... At the moment, our table has got players from both teams in it and we don't want that, because we're building a dashboard that will show us one team at a time.

Drag "Team" from the Dimensions area and drop it in "Filters".

You'll get a pop up showing you Liverpool and Everton. Tick Liverpool and click OK.

Now our table only has Liverpool players in it. Name the worksheet "Player List" (double click the worksheet's tab at the bottom of the screen) and then we're done with this one for the moment.

Add a new, blank worksheet and we'll also make a chart for our dashboard.

Let's try for a chart that will show us who's played a lot of minutes and who's playing well.

Drop "Rating" from the Measures area onto the Columns shelf and "Pass Completion %" onto the Rows shelf.

Tableau will guess that you're trying to draw a scatter chart, because you've dropped Measures where you'd normally drop Dimensions.

What we've got isn't tremendously useful though. It's a scatter, but with all of the players summed into a single point and we want them split out.

Drop "Player Name" onto Detail in the Marks area and Tableau will give you a point for each player.

Detail is essential for scatter plots and for maps. It tells Tableau at what level you want to see your data split out.

This still isn't a great chart though. Nobody has really low passing percentages or a really low rating, so let's tell Tableau that we don't need to see zero on the axes. Right click each axis, choose "Edit Axis", untick "Include Zero" in the top right corner, and press OK.

We're getting there. The chart shows who has good pass completion and who gets a good rating on WhoScored. If you hover the mouse over a point, it will tell you which player it is and whoever is up in the top right hand corner has good passing and a good WhoScored rating.

We can do better than that though. Grab "Mins" from your Measures area and drop it on Size.

Now the chart is showing who's played well (ish. This isn't very advanced analysis!) and whether they've had lots of minutes this season. Larger blobs means more minutes.

Drop "Team" from Dimensions onto Color and you'll be able to See Liverpool and Everton separated out. It would be nice if Liverpool were in red though...

Double click on a colour in the legend and you can change it.

(Worried about colour blind people? You could drop "Team" onto Shape as well. Don't leave it there though, because it will look a bit rubbish and we're only going to show one team at a time in a minute.)

Finally, drop "Player Name" onto Label and suddenly you'll be able to see who's who.

Rename your worksheet to "Player Scatter". We've got two worksheets and can build a dashboard!

The idea of dashboards is that you can drop multiple worksheets onto them and link them together. It lets you build screens that contain a mix of tables, charts and maps, where each piece of the dashboard is coming from one worksheet.

Make a new dashboard screen, by clicking the button next to your sheet tabs at the bottom of the screen.

In the new dashboard screen that pops up, you should see all of your worksheets appear in a list in the top left. Grab "Player List" (you did rename your sheets, didn't you?) and drop it onto the large white dashboard space.

The table you built earlier appears.

Now grab "Player Scatter" and do the same thing. Keep the left mouse button held down and you can see what will happen if you drop the worksheet into different places - at the top, on the left, or on the right. We want it on the right.

You should get something like this. Tableau put the chart on the screen and also the legend for your chart in separate boxes on the right hand side that you can move if you like. It looks rubbish. We can fix that.

Depending on the resolution of your monitor, Tableau has drawn you a default dashboard screen size and shape, but it's unlikely to be exactly what you want.

As a little aside, you can tell Tableau to draw a fixed dashboard size - that will never change no matter who loads it - or one that will try to adapt to different users' monitors by resizing itself. In my opinion, dashboards that resize themselves are usually crap and to be avoided. Tableau's not good enough at reshaping each element on the screen and if somebody loads your lovingly constructed views on a low res monitor, they'll look awful. You can set limits to the resizing, but it's much better to just fix the size and make users with low resolution screens scroll around a bit.

Use the dashboard size options in the bottom left to make a screen that is Exactly ('Exactly' is in the dropdown box) 1150 x 600.

That gives you a nice widescreen shape that will fit on a decent resolution laptop monitor. If you find it's half off your screen and there are scroll bars, you can make it smaller if you want.

Now that you can see both of your dashboard elements properly, it's time to make this dashboard interactive.

Remember adding the Team filter to your table so that it only showed Liverpool? We want to show that filter on this dashboard screen.

If you click in the area occupied by "Player List", you'll see a grey box appear around it. In the top-right corner of that grey boundary box, there's a tiny little down arrow, next to the x. It's really small but it is there and it's one of the things brand new users tend to miss.

Click that little down arrow, find "Quick Filters" and click "Team".

The filter that you created earlier will be pulled onto the dashboard, with only Liverpool ticked. If you hadn't already created that filter, Tableau would have just made it for you and also automatically put it on the underlying worksheet.

Tableau's default filter for a text column like Team, is a list of options with a tick box next to each, so in this case you get an option for Everton and Liverpool and (All) at the top. Sometimes this is what you want, but we'd like this dashboard to just show one team at a time, with no option to select both.

Filters have options on a little down arrow, just like the one we used on the "Player List" screen. Click in the area that your filter is occupying so that its grey boundary box is shown and use the menu to select "Single Value (Dropdown)".

That's given us a tidier dropdown box that will always take up the same amount of space on the dashboard if later on we decide to add more teams to our data.

You can also get rid of the (All) option on that box, so that people are forced to choose a team. In the same menu you just used, go to "Customize" and untick "Show All Value".

Our menu is ready!

Well, nearly. Change it from Liverpool to Everton and watch what happens. The table will switch from Liverpool to Everton, but the chart stays the same. That's no good. Currently, the filter is only linked to our table, not to our chart.

Use the menu on the filter (tiny little down arrow again) one last time to select "Apply to Worksheets" and "Selected Worksheets".

Then tick "Player Scatter" in the box that pops up and click OK.

Now try changing the filter. You've got an interactive dashboard!

When you add filters, you can choose to apply them to just one worksheet, to a selection of worksheets, or to everything that uses this data. The key thing to bear in mind is to make it obvious to users how your dashboard works. Filters that randomly change some things but not others are really, really confusing.

As far as this quick introduction goes, we're done! You've acquired data, loaded it, drawn tables and charts, built a dashboard and made it interactive and that's quite enough for today.

The only thing that remains is to share your masterpiece with the world.

In the File menu at the very top of the screen, click "Save to Web".

You'll get a popup box asking for your Tableau Public login. Remember your Tableau Public login? You made it in Part 2.

Give your workbook a name and hit Save. After a few moments, Tableau will pop up your workbook in all its glory, on the web. You can share it with anybody from here and they'll have exactly the same interactivity through filters, as you did in the desktop software.

Here's my version.

Helpfully, just as I wrote this guide last weekend, Tableau completely overhauled the look and feel of the old Tableau Public site. Thanks guys. Suffice to say, there are share and download links on the web dashboard screen and you can also access your profile and any other dashboards you've uploaded. Have a browse around the site and all will become clear.

Tableau really is a fantastic tool and you can achieve amazing visualisations, much faster, than with anything else I've come across (and I reviewed quite a few). I love it and I hope these three posts will help to remove that initial trepidation for a few football analysts. Get stuck in, connect to data and start playing. You'll get it and if you don't, Google it. And if you still don't, feel free to tweet me @neilcharles_uk.

No comments: