Hello everyone!

Today I want to show you how to calculate the number of days between orders of each customer using the sample super store dataset. As you can see from the below picture, the gantt bar shows the date of ordering for each customer, and we want to calculate the duration between these dates. To do this, we will need to use table calculation, along with some functions as following steps:

To do that, first, we will need to create a calculated field to calculate the duration by using DATEDIFF function as below. (Tip: if you don’t remember how to use DATEDIFF function, you can always click on the little arrow to expand the window on the right where you can find all the functions available, along with examples).

Then you can drag this calculated field Duration into the Size mark card and it will reflect the duration between the orders accordingly. If you don’t get a view like the picture below, you probably will need to check the compute using in the table calculation by right click on Duration and choose edit table calculation.

Make sure to your options are as shown in below picture. To explain this, it is the calculation will be computed by day and order date and it restarts for every customer.

And now, you can give yourself a challenge by trying to build a chart like below. If you need help, this is a #makeovermonday challenge which you can find here. Or you can always ping me and I’ll give you a hand.

Thank you for reading my blog. See you next time !



Sammy Do
Author: Sammy Do

Data Analytics Consultant who loves visualising data and driving meaningful insights