Add sparklines in Tableau, just another way to Enhance Tables

Add sparklines in Tableau

There are many methods to enhance tables in Tableau, and to add sparklines is one of them. We like to create sparklines because they offer great visibility, they are easy to follow and interpret. They look like thick line charts without an axis and are very suitable for time visualisations.

sparklines in Tableau

Imagine that you want to see monthly patterns in your data and observe the minimums and maximums. Their particularity is that they don’t start with 0, it’s hard to compare them with other graphics, and they are good for showing seasonal evolution.

sparkline in Tableau

The specific term for this type of chart is Density. Information is condensed in a small representation and the sparklines tend to be very concise representations. Sparklines were proposed by Edward Tufte in 2004 and its purpose was to represent in a typographical way a graphic anywhere in a presentation: next to words, headlines, inside of a map and different spreadsheets.

sparklines Tableau

(photo source – Tableau.com)

We won’t keep you waiting too much with an introduction, so let’s see exactly which are the steps in adding sparklines in Tableau to enhance your tables.

In order to create a Sparkline in Tableau, please follow these steps:

Step 1: Connect to data

→ In Tableau Desktop, connect to Superstore sample data provided by Tableau.

Step 2: Create the visualization

→ Create a New Sheet, add Subcategory on Rows, Order Date on Columns and change the period from YEAR to MONTH, continuous.

→ Create a Calculated Field named Lines with the below formula and add it to Rows:

ZN(LOOKUP(SUM([Sales]),0))

→ Create another Calculated Field named Dots with the below formula, add it to Rows.

IF ZN(LOOKUP(SUM([Sales]),0)) = WINDOW_MAX(ZN(LOOKUP(SUM([Sales]),0)))

OR ZN(LOOKUP(SUM([Sales]),0)) = WINDOW_MIN(ZN(LOOKUP(SUM([Sales]),0)))

THEN ZN(LOOKUP(SUM([Sales]),0)) END

→ Create a dual Axis between Lines and Dots, and then Synchronize Axis.

→ Create a Calculated field names Sales-Top/Bottom Color with the below formula and add it to color on Dots Mark:

IF ZN(LOOKUP(SUM([Sales]),0)) = WINDOW_MAX(ZN(LOOKUP(SUM([Sales]),0)))

THEN “Top”

ELSEIF ZN(LOOKUP(SUM([Sales]),0)) = WINDOW_MIN(ZN(LOOKUP(SUM([Sales]),0)))

THEN “Bottom”

END

→ Remove the Headers then add the sheet in a separate container and adjust it to fit in your table.

For even more clarity here is a video tutorial created by our Data Specialist, Ana-Maria Scarlat.

These miniature graphics are essential for interpreting costs and risks, and are very useful in business intelligence and management. Dense data visualisation like sparklines can be very fun to create with Tableau and we encourage you to do so.

DOWNLOAD TABLEAU SOFTWARE