5 Replies Latest reply on Jun 8, 2017 12:39 PM by Andrew goecke

# Calculating DateDiff function with single date dimension using other dimensions as filters

I need to take the difference in dates based on a few specifications within my data set.  I need to have the date difference based on a single date column, using an identifier labeled transaction type and price, separated by customer number. The calculation will start with the date marked with a 'P' for purchase. Then I want to know to difference between the customer's Sale date, which is marked with a transaction type: 'S'. Now, multiple transactions can occur for a single customer, so I need the calculation to specify which Date:Type'P' and Date"Type'S' to use in the Date Diff formula based on similarities in price. The tricky part of this is that the price field does not line up exactly, often similar, but the purchase price and sales price usually differ by a dollar or so.

I have attached my sample data and combined workbook. Thanks-Andrew

If my explanation was not clear enough, I need the DateDiff between each record that is connected via color string in the screenshot below.

• ###### 1. Re: Calculating DateDiff function with single date dimension using other dimensions as filters

Create two LOD calcs as below (one Min date and other Max date) and then a third date diff calc between the two LOD calcs.

• ###### 2. Re: Calculating DateDiff function with single date dimension using other dimensions as filters

Could you attach your workbook? The screenshots are a bit hard to read on my laptop.

Thanks,

Andrew

• ###### 3. Re: Calculating DateDiff function with single date dimension using other dimensions as filters

also, what did you do for rounded price?

Thanks,

Andrew

• ###### 4. Re: Calculating DateDiff function with single date dimension using other dimensions as filters

The workbook is in 10.3.     Rounded price was just      round([price]/100)  since all yours were in multiples of 100.

• ###### 5. Re: Calculating DateDiff function with single date dimension using other dimensions as filters

It is unfortunate that I can not open tableau 10.3.

Is your date diff function just the difference between the two LOD functions?