dev3lopcom, llc, official logo 12/8/2022

Connect Now

Welcome; let’s discuss making a sparkline chart on Tableau desktop. If this is your first time creating a sparkline in Tableau Desktop and you’re breaking into the data industry, maybe you’re still learning the power of data visualization in data science; know you’re on the right track.

For new Tableau users and pros – we break it down step by step.

Like our monster comprehensive API guide, we enjoy breaking apart information.

If you need help with this visualization, we would happily help you build a sparkline chart in Tableau.

6 steps to make a sparkline chart in Tableau Desktop.

  1. Open Tableau desktop,
  2. create a line chart
  3. build a calculation using if last()=0 then MEASURE end
  4. dual axis the calculation
  5. sync your axis
  6. hide the indicator

Here are the corresponding screenshots to help you see what’s happening.

Building sparklines in Tableau Desktop is quick and easy.

#1 Building a Sparkline chart – Open Tableau Desktop.

If you don’t already have Tableau Desktop, you should download Tableau Desktop, and install Tableau Desktop.

Once you have Tableau desktop activated and running – open any data set. We use the Super Store Subset for our tutorial example and want to visualize the running average of profits.

We like using running averages to smooth out the lines and clearly show what’s happening per Category.

#2 Building a Sparkline chart – Make a line chart.

Usually, we would drag this part of the tutorial out, but if you’ve made it this far, you already know to double-click your measure, change the marks to a line chart, and have a date on the other axis.

If you need more assistance building a line chart, check out Tableau’s extensive Online Help.

#3 Building a Sparkline chart – Build a calculation.

We’ve seen a slew of scary-looking calculations over the years – especially regarding sparklines.

You don’t need anything complex for this portion of the work.

if last()=0
then MEASURE
end

//that’s all folks.

You can drag and drop any table calculation you’ve generated into a calculation and be done with it! Here’s what our running average calculation looks like in the screenshot below.

optimized sparkline calculation in a tableau calculation alt text
Understanding Tableau Calculations is the first step to offering quality user experiences.

For the sake of the demo, let’s call your sparkline calculation spark.

Drag this next to your measure value – your current line chart in Tableau.

#4 Building a Sparkline chart – Dual axis your measure with your spark calc.

Next, to create the “sparkline in Tableau desktop,” you must add both measure values, dual axis, and synchronized.

Dual axis your measures.

Dual axis your measure with your sparkline calculation.

  1. Right-click your measure
  2. And click dual-axis

#5 Building a Sparkline chart – Synchronize axis.

Step 5 – synchronize the axis to ensure your upcoming sparkline chart is on point on your line chart.

If you don’t see your header, right-click on the measure and show the header.

Click on Synchronize Axis, and you will probably see the light now.

To ensure your sparkline circle lines up with your line - synchronize the axis.
To ensure your sparkline circle lines up with your line – synchronize the axis.

#6 Building a Sparkline chart – Hide Indicator.

You’re nearly completely done! There’s an indicator showing your ‘lack of an else’ in your if statement. Avoiding the ELSE is essentially fewer computations for your computer and Tableau. Leaving off else lets us avoid bothering with writing extra code, too.

if last()=0
then MEASURE
//ELSE 0 — not necessary
end

And because there’s a clear void in the data, the indicator will appear – we didn’t break anything, and the product is working as intended!

If you need any data engineering consulting or Tableau support, please contact our Tableau consulting team.