MIP Logo

How to Calculate the Duration between Orders for Customers

This post was originally published on The Data School blog between 2018 and July 2025, before our program was renamed to MIP’s Analytics Career Accelerator. References throughout this article to “The Data School” or “DS” all refer to what is now MIP’s Analytics Career Accelerator. The program, its people, and its commitment to launching outstanding analytics careers remain the same – just under a new name.

If you are having trouble viewing this article, please report it here

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 !

 

 

Share this post