I forget how to do this so often, that I figured writing it out might give me a fighting chance of remembering. It’s already something that Andy Kriebel has created a YouTube clip about, so there’s really no justification for my repeated memory lapses.

Sparklines are a nice way of concisely depicting the variation of a particular Measure over a period of time. They aren’t about precision and tend to be shown without axes, and can be used to show a number of dimension members in distinct rows / columns.

Using Sample – Superstore in the Tableau 10.2 Beta, here’s a really basic view of sparklines:

screen-shot-2016-12-08-at-21-11-19

A continuous time Dimension, a Discrete Dimension to chop the view up on Rows, and a continuous Measure (Sales). Other than that, I have:

  1. Reduced the x-axis by dragging it in from the right
  2. Reduced the y-axis by dragging it up
  3. Removed a few titles
  4. Edited the y-axis to uncheck “Include zero” and enable “Independent axis ranges for each row or column”

So we’re almost there, it’s the damn dots on the end that I always forget. How is it done? First of all, it’s a calculation that I previously failed to understand, but I get it now:

screen-shot-2016-12-08-at-21-04-46

What does the LAST function do?

screen-shot-2016-12-08-at-21-05-35

LAST()=0 is basically ensuring that there are no Rows between the current Row and the end of the range of the partition. It’s a Boolean sort of logic: Is this the last Row in the partition? It is? Then return SUM(Sales). It isn’t? Return nothing.

Once you have the calc, you need to decide where to put it. Look what happens if I drag it to a shared axis:

screen-shot-2016-12-08-at-21-11-51

It naturally is in sync, as there’s nothing to synchronise as the two Measures are on the same axis scale. I can edit the colours so the line appears as one colour, and the Last Sales calc is another, but I can’t independently colour each Line to depict the different segments:

screen-shot-2016-12-08-at-21-14-55

If I want to assign a colour for each Segment and a standard colour for each dot (Last Sales calc), I need to get the Measures onto separate axes. When initially dragging Last Sales from the shared axis to its own axis, I inevitably get synchronisation issues. Note how the dots aren’t tied to the end of the lines:

screen-shot-2016-12-08-at-21-16-26

If I sync the axis, remove the Last Sales header, remove Measure names from Colour on All Marks, put Segment on the primary axis Colour and make the Circles black, things end up looking rosy:

screen-shot-2016-12-08-at-21-19-27

This is not a game-changing post, but hopefully it (finally) makes this simple concept imprint itself into my fickle memory bank.

Advertisements