7 Replies Latest reply on Aug 21, 2018 2:12 PM by Jim Dehner

# Finding the Difference in days between orders by customer

Hi Community,

I have tried everything. From using ranks to lookups to levels of details and I am at a loss.

I am trying to find the number of days difference between orders at a customer by customer level.

The data is structure as so..

CustomerOrder NumberOrder Date
Days from previous order

X

12344/9/2018This is what I am trying to calculate
21454/20/2018*Calculation should read 11* etc
26545/16/2018
35896/22/2018
12566/25/2018
Y23545/4/2018
78545/20/2018
69875/28/2018
35746/5/2018

If anyone has any idea as to how to solve this please let me know. I am not able to share the exact data but my goal is to classify the time between each order and eventually put that number into buckets for further analysis. I have come across countless obstacles to finding this seemingly simple solution so any help is welcome,

Thanks.

• ###### 1. Re: Finding the Difference in days between orders by customer

see below

the formula is

set as shown

Jim

If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

1 of 1 people found this helpful
• ###### 2. Re: Finding the Difference in days between orders by customer

If needed, you CAN share a workbook.

Check out the video here:

But I think something like this should work:

DATEDIFF('day', LOOKUP(attr([Order Date]),-1), ATTR(Order Date]) )

This is a table calc, so depending on how you have your sheet set up, you might need to tell tableau the dimensional order in which to evaluate it.

If I had a sample workbook, I could show you that.

• ###### 4. Re: Finding the Difference in days between orders by customer

Thanks Jim,

I was trying that but without the min function. The lookup function wanted an aggregation or a constant and I didn't know how to satisfy that requirement with a date.

This formula works.

• ###### 5. Re: Finding the Difference in days between orders by customer

MIN, MAX, AVG, ATTR ...  These are all ways to satisfy Tableau's thirst for an aggregate.  Often all result in the same thing, but sometimes not.

I'm going to mark Jim's reply as the correct answer here.

1 of 1 people found this helpful
• ###### 6. Re: Finding the Difference in days between orders by customer

Thanks Joe,

Good to know. I couldn't share the workbook due to privacy issues but I appreciate your help as well.

Xander

• ###### 7. Re: Finding the Difference in days between orders by customer

Thanks Joe