Recently, I challenged Pooja to visualize some football data for #DuoDare 5. We looked at the game log stats for three Hall of Fame NFL quarterbacks. There were over 15 different measures in separate columns in the data set (Passing and Rushing stats).
I quickly decided on a long-form scrolling story optimized for mobile. Having just three quarterbacks lent itself perfectly to a design of three columns. I wanted all the interaction options to be visible and to be taps. I didn’t want any clunky drop-downs or radio buttons for the mobile experience. I started to plan out the sections of my story. Once, I had an idea of what I was going to visualize, I started to actually try and build it.
I am lucky to work with some very talented folks. Curtis Harris is one of my inspirations and a great friend. I really enjoy being able to bounce ideas off of each other every day. Recently, he talked to our team about user experience (UX) and design. He showed some mobile apps that everyone is familiar with like Stocks for iOS. As shown in the GIF, a user can simply tap the time period above the chart to change the view. It is simple, clean, intuitive and seamless. The selected time period is shown in white, while the others are grayed out. The x-axis labels update to match the time period.
I set out to incorporate something like this for my visualization. I wanted users to be able to tap to change the visualized passing statistic, a specific quarterback or all quarterbacks, or the chart aggregation.
Wait a second, did I say chart aggregation?…that would require a parameter with a clunky drop-down or radio button that doesn’t match the clean look I am going for in this chart, right?
Talking About the Data
It easy enough to create a button in Tableau using bars and MIN(1) on a fixed axis. This is the kind of selector I wanted to create. A user taps a button and it is highlighted in white like the Stocks app or it is grayed out. I used Measure Names/Values to create this view.
However, if you’ve used Tableau for any length of time, you know how this story is going to end. You drop this sheet on your dashboard and go to setup a filter action only to remember that you cannot filter by measure names. Don’t pretend like this hasn’t happened to you….
So I spent the next 20 minutes or so trying for the 100th time to fake out Tableau. Maybe if I use the discrete value of index computed along Measure Names? Nope, can’t do that. Ok, Maybe if I compute it table across? Nope, can’t do that. I think I’ve tried to hack this about a 100 different ways without success. What is really frustrating is that you can do a highlight action using Measure Names, so it appears the functionality exists to some degree.
Tableau, please give us access to Measure Names/Values in all the places (Calcs, actions, everywhere). Thanks! If you saw my tweet earlier in December, you now know why…
Dear @tableau Santa- Access to Measure Names/Values in calcs and actions (all the places) for 🎄 Xmas Please. Thanks, I’ve been good!
— Adam Crahen (@acrahen) December 20, 2017
Ok, so now what? I really didn’t want to pivot my data. I knew it would create a lot more rows, but sometimes working with the single pivot names / pivot values fields is annoying. I usually end up creating new measures so the individual measures can be formatted properly. Sometimes pivoting is perfect and sometimes it is a headache. Also, changing the aggregation on a chart would require a parameter so pivoting wouldn’t solve that nut.
Simple Joins Save the Day
I created a scaffold for the data using two additional Excel tabs in the same workbook.
For the Stat Selector, I listed every stat (duplicated for each Player). For the Chart selector, I listed the two options I would have included in a parameter (duplicated for each Player).
I joined this data in Tableau using Inner Joins all on the Player field. The third pill in the data prep window is the actual data. These are the three tabs of stats unioned together.
This method does duplicate the data, but I wasn’t too worried about that. I only had 693 records and the join resulted in 12,474 records or 18x my original data. For the record, Tableau’s pivot would have produced over 10,000 records anyway.
Working With the Data in Tableau
For any chart that did not need this scaffold, I simply filtered on one stat and one chart (it does not matter which one because the data is duplicated for all of them). I applied this filter to selected sheets and didn’t have to mess with pivoting the data.
For the sheet that is going to be affected by UX I was trying to create, I used dashboard actions. These actions were configured for the specific source/target sheets, select action, leave the filter on clearing and targeted filters.
I had two of these to control the stat and chart selector options. I created a third action for selecting the quarterbacks. I used grand totals to select all three QBs and some calcs to make the label appear as I wanted.
I created a few calcs to control the UX for multi-selections. I wanted to allow the user to select any number of QBs, one or both chart aggregations, but only one stat at a time. If you select more than one stat, only the first alphabetically will appear.
I published the workbook with selections made so it was intuitive for the user that they can change the view.
That’s it! With a few simple joins, I was able to customize the UX across filters and parameters alike.
Download the workbook for more details. There are a lot of tricks in there including conditional images based on the game result via Viz in Tooltips, calcs to strip decimals, to display aggregates, etc. in titles, captions, panes. I spent a long time customizing every interaction and thinking about how a user would use dashboard.
I hope this was useful. Thanks for reading.