Creating Sparklines

Published: 24 Apr 2017
Last Modified Date: 16 Jan 2019


How to create a sparkline view.


Tableau Desktop


The example uses the Superstore sample to create a sparkline that shows sales and profit for various product categories over a long period.

Create the View

  1. From the Dimensions pane, drag Order Date to the Columns shelf
    1. On the Columns shelf, right-click Order Date and select the second instance of Day
      Alternatively, if you want to view the profits over four years on a continuous axis, select the second instance of Month.

  2. From the Dimensions pane, drag Category and Segment to the Rows shelf
  3. From the Measures pane, drag Sales to the Rows shelf
  4. On the Columns shelf, right-click Month and uncheck Show Header
  5. On the Rows shelf, right-click Sales and uncheck Show Header

Optional: Add a Text Column for a Measure

  1. Select Analysis > Create Calculated Field
  2. In the Calculated Field dialog box that opens, do the following, and then click OK:
    1. Name the calculated field. In this example, the calculated field is named "Profit per Category per Segment"
    2. In the formula field, create a calculation similar to the following:
    3. { EXCLUDE DATETRUNC('day', [Order Date]), [Segment] : SUM([Profit]) }
  3. Right-click Profit per Category per Segment in the data pane, and select Convert to Discrete
  4. Drag Profit per Category per Segment to the Rows shelf


Additional Information

A sparkline chart is characterized by its small size and data density. Typically displayed without axes or coordinates, sparklines present trends and variations associated with some measurement, in a simple and condensed way. Whereas the typical chart is designed to show as much data as possible, sparklines are intended to be succinct.

Notes on adding a text column for a measure:
  • Without the level of detail (LOD) expression EXCLUDE, the SUM(Profit) would return a different value for every day of [Order Date] and every segment, which will create a new row for every different value of profit. The EXCLUDE expression computes SUM(Profit) as if DAY(Order Date) and [Segment] was not  included in the view.
  • DATETRUNC('day', [Order Date]) was generated by dragging DAY(Order Date) from the Columns shelf after EXCLUDE in the calculation editor.
  • All dimensions from the view (except for the dimensions on the Rows shelf) should be added after EXCLUDE

Discuss this article... Feedback Forum
Did this article resolve the issue?