Whenever the MLS Players Union releases player salaries, I use Tableau Public to visualize them, augmenting each one with new Tableau tricks that I’ve picked up in the months which separate these releases. Another release came out a couple weeks ago, but various obligations prevented me from visualizing it right away. In the meantime, Didier Drogba was signed by Montreal, Shaun Wright-Phillips joined his brother in New York, Nelson Valdez landed in Seattle, among numerous other signings around the league.
This sparked an idea: I added in the ability for readers to insert these signings or others of their own invention. At the bottom of the dashboard you will find a place to type in first name, last name, guaranteed compensation, and choose an MLS club for Player 1, with Drogba at $4.5m (figure I found from some rumor somewhere) by default, Player 2, and Player 3.
As you’ll notice, the players you insert into the chart will be in black, while the rest or in shades of green based on their base salaries, with the darkest hue reserved for those above the current Designated Player threshold, $436,250. Every time you insert or remove a created player from a club, the chart will automatically re-sort the rosters based on wages.
There’s also a filter allowing you to flip back and forth between the 2014 and 2015. Clubs re-sort themselves based on wages when you enact this filter, too. If a club, or even players, are selected at the time you change years, the selections will carry over and show you where they were in the other season. Your created players won’t appear in 2014 though, since there isn’t much point in inserting hypotheticals into a year that has already passed.
Feel free to use all of this interactivity, then take screenshots to illustrate points on Twitter, mentioning me @StatHunting if you’d like me to see your particular usage of the dashboard.
How To Do Something Like This in Tableau
A core truth in Tableau is that you can only work with the data available to you. I consider this a strong feature for the most part, because it makes it harder for someone to manipulate data in order to support their particular viewpoint. What about when you want to ask hypotheticals like we did above, though? That is one of the many use cases for parameters in Tableau. Parameters a very powerful way to give users a portal which they can use to input values or at least choose from a list. In this case, I created 4 parameters, then triplicated them, so that users could add three players to MLS clubs of their choosing and assign them a salary. The parameters look like this (I didn’t include Last Name in these images because it’s basically identical to First Name):
Then, as with all parameters, I needed a way for them to relate to my data source. In this case I needed to replace particular cells in my data source with these parameter values. I could have found an existing row in my data that was otherwise irrelevant (such as a “pool” player that isn’t assigned to a particular club), but in this case I chose to create some extra rows in my Excel data source:
|Club||Last Name||First Name||Pos||Base Salary||Compensation||season|
Every time you use a parameter you have to plug it into your data via a calculated field. In my case I made 4 different calculated fields with the following format:First Name*, Last Name*, and Compensation* where all organized the same way, simply changing the parameters on the right and the last use of the data field after “ELSE.” In english whe’re telling Tableau that when Club is “Unknown1,” then replace it with Player 1 Club, the same for “Unknown2” and “Unknown3,” and when that’s not the case, leave it as the value of Club in that row.
The last part is simply using Club*, First Name*, Last Name*, and Compensation* where you would their original fields. If you’ve already built something, use Tableau’s Replace References feature, a great shortcut for situations like this. For example, you right-click on Club in the Measures pane, select “Replace References…”, click “Club*” and OK, then every example of [Club] in calculated fields, shelves, etc. will be replaced with [Club*]. Go back to your calculated fields after doing so, as you don’t want First Name*, Last Name*, and Compensation* to start with “CASE [Club*]” instead of “CASE [Club].”
To make the parameter players stand out a little more, I set base salary to drive color in a custom diverging, black and green scheme, the mid-point set at $0 and using the full color range. Because the base salaries in our Unknown1-3 rows were all -0.001, they will be the only data points that show up as black, while the others’ hues are driven by how close they are to the 2015 cap maximum (aka DP level), $436,250.
I hope MLS fans enjoy the visual above (please tweet fun uses of it to @StatHunting), and that some other Tableau developers out there can find other use cases for this particular Tableau hack.