Addy
Addy

Reputation: 11

Create an 'Overlap' Flag in Tableau

I have two existing fields- Date_of_Order (the day that an order was placed) and Days_Supply (number of days the order was intended to last). I need to create a new field that will determine if there is an overlap between a new order and the previous orders. For example, if there was an order placed on January 1st with a days supply of 30, and the next order was placed on January 28th, this should flag as an overlap. Extra credit if you can help be calculate the number of days in the overlap (2 days in this example).

I tried creating a new field for order_end_date, then I used this new field and the days supply to create a flag. I'm trying to see if there are any other methods or ways to do this in just 1 calculated field.

Upvotes: 1

Views: 45

Answers (1)

Alex Blakemore
Alex Blakemore

Reputation: 11921

This might be easiest to calculate using Tableau Prep Builder before feeding the intermediate results to Tableau Desktop.

When calculations depend on the ORDER of records, then your choices are:

  • table calcs (requiring data be fetched client side)
  • custom SQL using analytic/windowing queries (which are computed server side) or
  • pre-computing info using the more recent features in Tableau Prep, roughly called LOD calcs in Tableau Prep (which are somewhat different than the LOD calcs in Tableau desktop)

The other types of calculations in Tableau either operate on individual data records (record level calcs) or on groups of records (aggregate calcs and LOD calcs). None of those types of calcs can depend on the order of the records. That’s fine, but it means they aren’t the right tool for this situation.

Upvotes: 0

Related Questions