CYBERTREND DATA ACADEMY
D. Metadata grid
6. Slicing Your Data by Date
Working with Dates in Tableau
For relational data source, Tableau automatically places dates and times in the Dimensions area of the Data pane. Date/time fields are identified by the date and time icon as shown below.
Note : Date hierarchies and attributes in OLAP (or cubes) are defined when the cube is created, and you cannot modify them in Tableau.
When you place a date on a shelf, the default field name reflects the highest date level in your data.
Understanding and Using Discrete and Continues Dates Continuous dates represent the chronological progression of time.
When you add a continuous date/time dimension to a view, Tableau creates an axis as a timeline. Use continuous dates when you want to show your data organized along a timeline, from the first data point in time to the last data point in time.
In contrast, when a discreate date dimension is added to the view, Tableau organizes the dates as discrete parts, independent of linier time, and creates a header. Use discrete dates to show your data organized by date units, such as aggregated data for all Novembers over several years.
These different time behaviors create different views. If the
date/time attributes of your view do not seem right for your data, you might need to change your date dimension to discrete or continuous.
Using Discrete Date Parts
You can move discrete date parts to different shelves or to a nonlinear order.
Reorder the Date Hierarchy
You can order discrete dates according to any hierarchy that produces the views you need. The view below shows Quarter before Year of Order Date, which allows a
CONFIDENTIAL DO NOT COPY
CYBERTREND DATA ACADEMY
Practice: Discrete and Continuous Dates
Discrete Months ViewCreate a bar chart to show the aggregation of sales by month of the order date. Use your visualization to determine the total sales for all years in a specific month.
Direction for Discrete Months View:
Open Discrete_and_Continuous_Starter.twbx and create a view according to the following specification:
1. Create a view for Discrete Dates:
From Measure, drag Sales to Rows
From Dimension, drag Order Date to Columns 2. Change the chart type to Bar. (Hint: Use Marks card)
3. Right click the Order Date on Columns and select the discrete month format.
CONFIDENTIAL DO NOT COPY
CYBERTREND DATA ACADEMY
Continuous Months View
On Sheet 2, create a line chart to show sales for each month of the order date in a continuous time line. Use your visualization to see highs and lows for sales over time and determine sales for a particular month and year.
Direction for Continuous Months View:
Using Sheet2 of Discrete_and_Continuous_Starter.twbx to create a view according to the following specification:
1. Create a view for Discrete Dates:
From Measure, drag Sales to Rows
From Dimension, drag Order Date to Columns 2. Change the chart type to Line. (Hint: Use Marks card)
Right click the Order Date on Columns and select the continuous month format.
CONFIDENTIAL DO NOT COPY
CYBERTREND DATA ACADEMY
Creating Custom Dates
Custom dates are calculated date parts you can save in the Data pane, and can be discrete (Date Part) or continuous (Date Value). Create a custom date so you can save and reuse the custom date part or value without having to override the default behavior for each use of the date.
Using custom dates also breaks the automatic date hierarchy Tableau creates and allows for each field to represent just itself – similar to a DATETRUNC ( ) function.
Create a Custom Date
i. In the Data pane, right-click on the date field you want to use for the custom date, point to Create, and then select Custom Date.
ii. In the Create Custom Date dialog box, in the Name field, give the new custom date field a meaningful name.
iii. From the Detail drop-down list, select the date type you want to use.
iv. Choose Date Part to set the date as discrete, and Date Value to set the date as continuous.
Practice: Custom Dates
Practice creating custom dates, then build a hierarchy to control and simplify your view so you only see sales by the date parts you need for more efficient analysis
Continuous Custom Date
CONFIDENTIAL DO NOT COPY
CYBERTREND DATA ACADEMY
Direction:
Open Custom_Date_Starter.twbx and create a view according to the following specification:
1. On the sheet named Continuous Quarters, create a custom date with a value of quarters, and name it “Order Date (Continuous Quarters)”. Use custom continuous dates are shown in quarters.
Hint : Right click on Order Date then create custom date 2. Drag the newly Order Date (Continuous Quarters) to Columns.
3. Uses a line chart of sales by order date.
Discrete Custom Date
Create a bar chart that shows sales by order date using a custom discrete date in quarters.
Direction:
1. On the sheet named Discrete Quarters, create a custom date with a value of quarters, change to Date Part, and name it “Order Date (Discrete Quarters)”. Hint : Right click on Order Date then Create > Custom Date
2. Remove the date field on the columns shelf, and drag this new field to Columns.
3. Change the mark type to Bar.
CONFIDENTIAL DO NOT COPY
CYBERTREND DATA ACADEMY
Discrete Year to Quarters Hierarchy
Create a bar chart that shows sales by order date using a custom discrete date hierarchy of years to quarters.
Direction:
1. On the sheet named Year to Quarter Custom Date Hierarchy, create a custom date with a value of years, change to Date Part, and name it “Order Date (Discrete Years)”.
Hint : Right click on Order Date then create custom date
2. Drag the Order Date (Discrete Quarters) to the custom years date field Order Date (Discrete Years) to create a hierarchy named “Order Date (Discrete Years to Quarters)” and drag to the view.
Change the mark type to Bar.