KNOWLEDGE BASE

## Show Only Events Occurring Within N Days of One Another

Published: 09 May 2017

### Question

How to filter the view to show only high frequency dates. For example, all orders that occur within 30 days of another order.

### Environment

Tableau Desktop

The attached example workbook uses the sample data set Superstore to demonstrate the following instructions:

1. Create a calculated field with a name like Within 30 Days Filter and a calculation similar to the following:
`DATEDIFF( 'day', LOOKUP( MIN( [Order Date] ), -1), MIN( [Order Date] ) ) <= 30 OR DATEDIFF( 'day', MIN( [Order Date] ), LOOKUP( MIN( [Order Date] ), 1 ) ) <= 30`
2. Drag [Customer Name] and [Order Date] to the Rows shelf
3. Drag [Within 30 Days Filter] to the Filters shelf and click OK in the Filter dialog to close it.
4. Right-click on [Within 30 Days Filter] on the Filters shelf and select Edit Table Calculation
5. In the Table Calculation dialog, do the following and then close the dialog:
• For Compute Using, select Specific Dimensions
• Ensure that both dimensions are checked. (They should be checked by default).
• For Restarting every, select Customer Name
6. Right-click on [Within 30 Days Filter] on the Filters shelf and select Edit Filter...
7. In the Filter dialog, check only True and click OK