Have you ever encountered the need to calculate the difference in a measure row compared to the value of the previous row? This is called a Running Difference.

A lot of times we encounter that we need to perform Running Sums in our calculations. Those are easy to do as Running Sums are one of the most used table calculations and we have them also available as a function. Sadly, this is not the case for Running Differences.

1

In this blog, I will show you how to calculate them with ease.

Let's create a Running Difference!

For our data source let's take our beloved Sample Superstore.

Let's say that we will like to calculate the difference in our sales per month for the Year 2022.

1

To calculate the Running Difference it is as easy as creating a calculated field with the following:

1

Now add it to your view and you will have the difference in sales month per month

1

This Running Difference also works if not all your months are filled-in. This is because of the fact that it is a table calculation. The difference is not done with the calendar last month, it is done compared to the last record of the table.

If you would like the first record not to show a value, then you will need to add an IF clause to compute a zero in its place.

1
1

There you have it, now you know how to calculate a Running Difference in Tableau!

For more tips and tricks about data visit our website: https://theinformationlab.nl/en/blogs/

Tags: