KNOWLEDGE BASE

Using Custom Date Levels


Product(s): Tableau Desktop, Tableau Public
Version(s): All
Last Modified Date: 16 Aug 2016

Article Note: This article is no longer actively maintained by Tableau. We continue to make it available because the information is still valuable, but some steps may vary due to product changes.


In Tableau, date fields are automatically separated into levels, such as Year, Quarter, Month, etc. You can easily switch among these levels, as well as use the date multiple times at various levels of detail in a single view.

Sometimes, however, you may want to separate a date into non-standard increments, such as 2 months or 15 minutes. You can separate a date field into any sized increment with a simple calculation and the bins feature.

Note: These directions assume you are using a relational data source. Additional setup is required to use this method in multidimensional data sources (MSAS, Essbase).


The view below shows the average arrival delays for flights out of Seattle into four different cities, broken down by day of the month.

However, suppose you want to view the same data, only this time broken down by every 5 days. First, you need to create a calculated field that includes only the day values from each record. Then you can bin those days into 5-day increments.

Step 1 

Select Analysis > Create Calculated Field.

Step 2 

In the Calculated Field dialog box, make the following selections to create this formula:

DATEPART('day', [Flight Date])

  1. In the Name text box, type Flight Delays.
  2. Press the Tab key to move the cursor to the Formula text box.
  3. In the Functions list, double-click DATEPART.
  4. Type 'day', and space once.
  5. In the Fields list, double-click Flight Date.

Step 3 

When finished, click OK.

Step 4 

In the Measures pane, right-click Flight Delays and select Create Bins.

Step 5 

For this example, in the Create Bins dialog box, in the New field name text box, type the name "5 Day Intervals." Then in the Size of bins text box, type a 5.

Step 6 

Click Load to populate the Range of Values text boxes, and then click OK.

The binned field is displayed in the Dimensions pane because it contains discrete categories of data. After you replace Flight Date with 5 Day Intervals on the Columns shelf, the view shows the data aggregated into 5-day intervals.

Note: You can use this technique to look at a variety of custom date and time levels by specifying a different DATEPART in the calculation. For example, if you wanted to look at 15-minute increments, you would replace "day" with "minute" in the formula.

 

Alternate Search Terms:date, date levels
Did this article resolve the issue?