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.
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.
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.
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.
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]
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.
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.
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.