3 Replies Latest reply on Mar 15, 2016 7:00 PM by Ekaterina Gordon

# Calculating the gap between purchase dates for each individual customer

Hi everyone,

I've looked through the forum topics related to the subject, but couldn't find quite what I need to calculate.

Here is how the data-set looks like:

UserID     OrderDate

123          01.01.2015

234          02.01.2015

345          04.01.2015

234          03.01.2015

234          06.01.2015

123          08.01.2015

I have a list of customers who are making purchases on different dates. Each purchase equals to a new record. Most of the customers purchase regularly hence their UserID is recorded as many times as they purchased. Only one record is made even if the same customer made several purchases on the same date.

Challenge:

I need to calculate the gap (in days)  between two resent purchases individually for each UserID. The expected result should look like:

UserID     OrderDate          Gap

123          01.01.2015          0

234          02.01.2015          0

345          04.01.2015          0

234          03.01.2015          1

234          06.01.2015          3

123          08.01.2015          7

• ###### 1. Re: Calculating the gap between purchase dates for each individual customer

Ekaterina,

• ###### 2. Re: Calculating the gap between purchase dates for each individual customer

Ekaterina,

Here's a workbook (Tableau 9.2.4) that has an example of what I did with your data and the reference article.  I hope it helps - it doesn't look exactly like the way you want it, but it does get the answer you need.

-Ann-