How to Visualize Only Every Nth Data Point in #Tableau

Introduction

There are times when I need to use a simple technique for reducing data density along a line in Tableau. I do this by showing only the Nth data point along a line by using a mathematically-based filter. In this article, I show how this is done.

The Data

Figure 1 shows the example data for this application. The data density is very high, with readings taken every 0.5 seconds. This data density is more than what is needed and makes visualizing the data marks for multiple curves on a single plot difficult. Figure 2 shows what I mean.

data

Figure 1 – The example data showing a data density of one reading per 0.5 seconds. There are 838 readings along the first data set and then a second data set starts in row 840. The index counter gets set to 1 for the second data set at this point (row 840).


Figure 2

Figure 2 – High data density leads to data marks that cannot be easily discerned.


The Solution

I implement a filter that is based on the modulo operator (%) that shows only the Nth data point along a line. The modulo operator returns a remainder of a calculation. When the remainder is 0, we want to show those data points. In this example, the filter I have created is called Keepit as is shown in Figure 2.

Keeper_formulation

Figure 2 – The Keepit filter that is based on the modulo operator (%). Once we activate this filter, we only want to keep the values of 0.


When the Keepit filter is used with a setting of 16 (keep data every 8 seconds), the data marks are identifiable as shown in Figure 3.


Five Graphs

Figure 3 – In this example, the parameter known as Keeper is set to 16. This keeps data from every 8 seconds of the experiments since the data collection interval was 0.5 seconds.


How This Works

This formulation keeps every Nth data point defined by the parameter [Keeper], with a shift applied so that the first data point is always included in the line. That shift occurs because of the ([Keeper]-1) term.  For example, if Keeper is set to 16, the data points with index 1,17,33 … will be shown on the graphic. This means that data from 8 seconds apart will be shown. This gives enough room between the data marks to easily tell them apart as shown in Figure 3.

For easy reference, the Keepit filter formula is: ([Index]+([Keeper]-1))%[Keeper]

Training Video

In the video shown below, I explain the basics of this approach without the shift applied, starting with indexing the source data. I think the video is easy to follow, so if you want more information, just spend three minutes to watch what I say about this method.



Final Thoughts

This approach works just fine for data that has been collected in regular intervals. What if the data were not equally spaced in time? Well, you could design a filter that uses a different formulation for eliminating the required data. You could use an exponential decay formulation or some other function (how creative are you?) to eliminate excess data points. There is no limit to what is possible in this regard.

Update

One of my favorite bloggers, Mr. Bora Beran, wrote a recent article that uses a similar technique to this for drawing various linetypes in Tableau. Click here for more information about his technique.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s