See all tips |
View as pdf
Using Custom Date Levels
|
In Tableau, date fields are automatically separated into levels such as Year, Quarter, Month, etc. You can easily switch between each of these levels as well as use the date at multiple times at various levels of detail in a single view. Check out Using Dates to learn more.
However, sometimes you may want to separate a date into non-standard increments, such as 2 month or 15 minute periods. You can separate a date field into any sized increment with a simple calculation and the bins feature. | |||||
Here's how it works.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, let's say you wanted to view the same data, only this time broken down by every 5 days. First, you will 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. | |||||
| 1. On the Data window title menu, select Create Calculated Field. | |||||
|
|||||
| 2. In the Calculated Field dialog box, name the new field. In this example we'll call it Flight Days. In the Formula text box, use the DATEPART function to include just the days of the date field. In this example, the formula looks like this: | |||||
|
|||||
| Check the formula to make sure it is valid and then click OK. | |||||
| 3. The new field displays in the Measures area of the Data window. Right-click the field and select Create Bins. | |||||
|
|||||
| 4. In the Create Bins dialog box, name the binned field. In this example we'll call it "5 Day Intervals." Then type the size of the interval into the Size text box. To show every 5 days, type 5. | |||||
|
|||||
| The binned field is displayed in the dimensions area of the Data window because it contains discrete categories of data. The view below shows the same data as before, except now instead of a mark for each day, the data is aggregated into 5 day interavals. | |||||
|
|||||
| 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, had you wanted to look at 15 minute increments you would replace "day" with "minute" in the formula. | |||||
|
|||||


![Type a name for the new field and then type the formula into the text box. For this example, the formula is: DATEPART('day',[Flight Date])](/files/0703_03.png)


