# Step lines and supported bars in Tableau

### Step Lines

I am a big fan of step lines (here is a good example from datasketch.es) so I was really excited to see that line type announced at last year’s Devs on Stage. While we wait for that feature to be provided directly within the product, we have two choices: (1) don’t use them, or (2) build them ourselves. Choice two is much more the DataBlick way, so I have tried to provide you with a few steps that you can follow to build this chart type yourself. You can also take a look at Tim Ngwena’s post here which details another method that you can look into for your use case.

Step lines are just lines at the end of the day. When I started looking into how to plot their points accordingly, the prep work reminded me quite a bit of the data prep needed for Jump Plot. We basically need to take our list of points and add an additional mark for each point, and potentially one at the origin (0,0) if that is desired for our viz (as it was in this case). I will be using step lines to help analyze the scoring to par across PGA tournaments this year.

Here is a small sample of the data we will be working with going forward, this is an aggregated data set, looking at the average score to par for pros on the PGA tour this year. We are going to plot “hole” on the x-axis and “Avg Score” on the y-axis to make our viz.

In order to build step lines, I did the following 2 data manipulations:

• I duplicated every record (and kept track of this using Path Order field)
• I added 1 record to the beginning of the data set to start the line from 0,0 (identified by hole = 0)

Here is what our original data looks like now. I used Alteryx for this data preparation step (but Excel/SQL would work fine as well).

Now we can bring our data into Tableau, before we go dropping any pills lets add a couple calculations first:

• X will replace “hole” as the pill we will be putting on the x-axis. We will force it to 0 if on our entry data point. If we are on the first of the two records for this golf hole, make the value the previous one (for this example a simple “–1” works, but you may need to change this). Otherwise use the current value (i.e., golf hole number).
• Y will replace “Avg Score” as the pill we will be putting on the y-axis. We will force it to 0 if on our entry data point. Since we are using Running Sum across our viz, we want to be sure we do not double count our data (as we have added extra rows). There are many ways to do this, I opted to make the value 0 on the duplicated points (thus the y value of our line will be unaffected by our added data points). You will also want to be careful here with adding 0s and having that inadvertently effect your averages.

Now we can start moving pills (follow this through as the view will look a bit off as you go):

• Move X to Columns (as a continuous dimension)
• Move Y to Rows
• Change mark type to line (if necessary)
• My data is at the level of tournament (add to detail) and golf hole (add to path)

That’s it! Once you drop hole onto the path shelf, you should now see your step line, as shown below…

From here, you can continue to add dimensions, create small multiples, etc. Enjoy!

### Supported Bars

In case you are wondering, yes, I did just make that name up for this post. Having admitted that, I do think it is a fitting name for the viz we will be going through. Basically we are going to create a synchronized dual axis bar chart, with two different levels of detail. A summary level and a slightly more granular level to support or help explain the number we see at the summary level. Looking back at our golf example, this view stemmed from asking questions like; Is this golf hole harder in the final round than the first? Does this potentially skew the average?

Here is the supported bar chart I built a few months back for my Masters viz

Thanks to Tableau, it is pretty quick to achieve this viz, here are the steps you can follow:

• Drag tournament, round and hole to detail
• Drag hole to columns
• Drag Index() to columns (compute using round)
• Drag AVG(Avg Score) to Rows
• Click size, select fixed and set width to 1 (left alignment works fine)

At this point you should have four bars for each hole (one bar per round), which looks like this…

We have the support for our main summary data point ready to go, now we just need to roll up to that summary:

• Ctrl + drag AVG(Avg Score) to duplicate the pill on the rows shelf
• Remove “round” from the detail shelf of the new pill
• Click size, select fixed and set width to 4 (or whatever your number of detailed points is)
• Set color to 50% or less opacity for summary level and set color of detail level to a lighter color as well.
• Dual axis + synchronize, move summary marks to front

Your view should now look something like this.

From here all that is left is the clean up of axes, labels, colors, gridlines, etc. Once all of that is done you can have a visual like below.

Put all of those pieces together into a single dashboard and you can start to answer questions like which golf tournament/course played the hardest this year on the PGA tour.

Happy Vizzing!

Comment