How to display a Tableau dashboard for Different Time Periods

Sometimes data in Tableau dashboards need to be displayed for different time periods. In this blog, we will see how to display a Tableau dashboard for different time periods such as for Year, Month , Week etc.

Steps to display a chart for different time periods

As a first step, we will create a simple chart with dimension as Date and measure as Sales.

1. Connect to Sample-Superstore.xls. This data source comes with the installation of Tableau. Use the Orders table. How to connect to XLS file in Tableau.

2. Create a Bar chart. To create a bar chart, from the Data pane, place Order Date on Columns and place Sales on Rows. If this creates a line chart, choose bar chart from Show Me. You can also work with the line chart.

Bar chart displaying Year-wise Sales
Bar chart displaying Year-wise Sales

3. The above bar chart is displaying Yearly Sales. What if you want to display the Sales for different time periods and provide an option to the user to select a time period such as Year, Month, Week etc.

How to display a Tableau dashboard for different Time Periods:

As a next step, we will create a Time Selection Parameter. This parameter will have values for Year, Month and Week.

  1. Right-Click anywhere on the Measure section (in data pane) and select Create/Parameter
Creating a Parameter
Creating Time Selection Parameter

Create Time Selection Parameter with the following settings

Parameter settings for Year, Month and Week
Parameter settings for Year, Month and Week

2. Create a calculated field to use this parameter. From the Analysis menu on the top, select Calculated Field. Specify the following calculation:

Date Selection calculation
Date Selection calculation

In the above calculation, we are using date functions to calculate Year, Month and Week from the Order Date. DateTrunc function truncates the date to the specified date part, in this case, week. Make sure to use the same spelling of Year, Month and Week as specified in the Time Selection Parameter.

3. Recreate the above bar chart using the Date Selection calculation.

From the bar chart, we created earlier, remove the Year (Order Date) and replace it with Date Selection calculation created in the above step 2.

Bar chart with Date Selection calculation
Bar chart with Date Selection calculation

4. Navigate to Parameters section at the bottom of data pane, right-click and select Show Parameter. The bar chart will display data according to the selection made in the parameter. 

5. You can do some formatting, specify Number format to Sales and create a dashboard. 

Dashboard changes according to the different Time Selection

Further readings:

How to dynamically change a chart based on Dimension selection in Tableau


About the Author

Chandraish Sinha has  20+ years of experience in Information Technology. He is an accomplished author and has published 11 books covering Business Intelligence related topics such as, Tableau,Power BI, and Qlik. Checkout his Amazon Author profile.

His latest book Excel Basics to Advanced covers all the aspects of MS Excel and provides exercises for self-learning.

Similarly, his recent book, Dashboarding with Tableau, covers all the features in Tableau and includes exercises for self-learning.

He has implemented IT solutions in different domains viz. Pharmaceutical, Healthcare, Telecom, Financial and Retail.

He blogs regularly on various IT topics. Check them out in the links given below: 

Blogs

Learn Tableau

Learn All Bi

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.