Online tableau training, tableau tips, & video tutorials

Chart Types

Memberships

How to Make Sparklines in Tableau

Preview

Instructor

Ryan Sleeper

Display high-level trends to provide a starting point for analysis

Learn how to use the generated fields, Measure Names and Measure Values, to easily create a series of condensed line graphs – or “sparklines”. You’ll also see formatting tips and an alternative method for displaying axis ranges.

Hi. This is Ryan with Playfair Data TV. And in this video, I’m going to be sharing one of my favorite foundational chart types, which is called sparklines. Sparklines are a series of condensed line graphs that are meant to be viewed at a 10,000-foot level to give you a first place to start and see if there’s any kind of trend you should be aware of, if there’s a major spike or any major drop, to give you a starting point for an analysis so that you can then dig deeper.

To start a sparklines view, we’re going to be using a special generated field in Tableau called Measure Names. Going to drag the Measure Names dimension to the Rows Shelf. And as you can see, Measure Names does almost nothing on its own. It almost always needs to be used in conjunction with another generated field called Measure Values. This is the counterpart to the Measure Names field.

If I put the Measure Values field onto the Rows Shelf next to Measure Names, what we see by default is every metric in my data set at its default aggregation. So we’ve got six different metrics that come with the Sample – Superstore data set. Most of them are aggregated by SUM– SUM Number of Records, SUM Profit, SUM Quantity, SUM Sales.

But we see a couple different ones. Discount is aggregated as AVG, or average. And then Profit Ratio is a calculated field, which equals SUM of Profit divided by SUM of Sales. And because that metric is an aggregate, we see an aggregation called AGG. That’s short for aggregate.

So so far, so good. There is one metric I want to get rid of, Number of Records. We’ll pretend that this is a real-world application. And we don’t really need to see how our number of records is trending over time. So if you want to get rid of any of the metrics in a sparkline view, all you have to do is drag it off of the Measure Values Shelf. And notice we went from six metrics or six rows to five metrics and five rows. So far so good.

The next thing we need to add to the view is some element of time. In the sample data set, that’s almost always Order Date. To add Order Date to the view, I’m going to right-click while I drag it to the Columns Shelf, because when you right click, it’s a shortcut to allow you to decide both the date part as well as if that date is going to be used as a discrete field or a continuous field.

We’ll pretend that for our sparklines view, we want to look at each of these five KPIs by continuous Month. That is the fourth option from the bottom. Month is the date part. And there’s a little green calendar icon next to it, which tells me that date will be used as a continuous field. So I’m going to click that and click OK.

And at this point, we essentially have five line graphs. A lot of people ask, what’s the difference between a line graph and a sparkline? Truth is, not much. They really are just condensed line graphs.

But when they were invented, they were meant to be so small that they could be read in-line in a text book. So you might be reading some metric or statistic or finding, then see a little tiny sparkline that tries to give you a little bit of a visual on how that statistic or finding was trending over time.

To make these line graphs more ‘sparky’, if you will, I’m going to hover near the right side of the chart. And when that arrow cursor appears, I’m going to left click and drag that into the left. And now we can see a lot more volatility with each of these five KPIs. It just is a lot easier to see big spikes or big drops in the data set.

Again, this is meant to be a very high-level overview. So some of this context in my opinion is muddying up the view. With a sparkline view, I might choose to hide the y-axis, which you can do by right-clicking and deselecting Show Header.

And this idea is a little more controversial. But I feel the same way about the x-axis. Right now that x-axis isn’t providing a lot of value to me. I can’t even see the start of the range and the end of the range. I just see two tick marks, one at 2016 and one at 2018. So I might go ahead and hide that as well by right-clicking and deselecting Show Header.

If you feel like you just have to see the x-axis, what I recommend you do is in the surrounding text, provide the start of the range and the end of the range, because that’s really what’s most important. And the reason I’m personally comfortable with not showing it at all is I believe that that information is typically provided in the surrounding context. On a dashboard or in a PowerPoint for example, I might say, here’s our trend over the last 48 months. Well, last 48 months, that’s the x-axis. I don’t necessarily need to see every single tick mark and have it muddying up the view.

To make this even more clean, from here all these formatting tips are optional. But you can right-click anywhere in the view and click Format. And there’s a tab for lines. I typically get rid of all of the grid lines and all of the zero lines. But again, this is optional. This might be a case-by-case basis, depending on what business you’re in, depending on what metrics you’re looking at. For example, it might be arguable that you’ll want to see a zero line for profit, because you could have positive values and negative values.

But the spirit of what I’m trying to do with this view is just clean it up. I’m very much a minimalist designer, and I prefer cleaner design. So I just got rid of some of those lines.

One alternative I wanted to share with you to the y-axis, I mentioned I like to hide that. Muddies up the view. And this graph is just not meant to provide that exact detail. I don’t need to see every single exact number.

But if you want to know the start of the range and the end of the range, an alternative way to do that that’s a little bit cleaner is to click on the Label Marks Card and click this box to turn them on. That’s the first thing. By default, Tableau will show as many labels as possible without them overlapping. So you can see that’s pretty messy at the moment.

But there’s some options under where it says, Marks to Label. You can choose to label only the Min and Max for each of our five rows. So this is significantly cleaner. And as a bonus, it’s showing us the lowest value and the highest value for each of my five rows. In other words, that’s my y-axis range that it’s displaying there.

One more tip for you to clean this up, notice there’s still a few values that don’t look great. And what’s happening is we’ve got black text on top of a blue mark. I’m always surprised when I come across people that haven’t come across this way to solve this.

But you can actually click directly on a label. And when that four-corner cursor appears, you can left click and drag this wherever you want. So you can line this up exactly as you want. Here’s another example with 27%. If I click on it, drag it next to the blue, and it’s just a lot easier to see.

But that’s sparklines in Tableau. This is one of my favorite starting points for a dashboard. Because it’s meant to be a starting point on my dashboards, you might see this along the left column or left-hand side of a dashboard or along the top, because I want to dedicate that valuable real estate so that my end user starts there. Gives them a very high-level overview. Tells them which metrics they might want to dig in deeper to later in the analysis.

This has been Ryan with Playfair Data TV – thanks for watching!