Introduction

Calendars help us keep track of events and appointments, and allow us to organise our daily lives. For example, a calendar might be useful to partition data by a date dimension to see what events took place on a particular date. This blog post contains detailed step-by-step instructions on how to build an interactive calendar that displays additional information based on the calendar date selected by the user.


In the following example, each date on which an order was placed is highlighted by a light blue circle. When selecting one of these days, all orders placed on that day will be displayed in the lower part of the view, along with some relevant order details. The blue and red pills on the right side of the table indicate whether a commission was dispatched on time or late (i.e. within 4 days of the order date or later).

The activities required to build out this view can be broken down into four main steps:

Step 1: Creation of the data model
Step 2: Creation of the calendar
Step 3: Creation of the order table
Step 4: Bringing it all together


Step 1: Creation of the data model

 

The data used for this dashboard is the 2022.1 US Superstore data set truncated to July 22, 2022 to create a realistic example where there are no orders for future dates.


As with any attempt to create a calendar in Tableau, there is the challenge of missing data for the days on which no data was captured, i.e. no order has been placed. To solve this problem, we use a date scaffold, a table that contains only one column with a list of dates that we want to see in our calendar. This allows us to display also dates on which no order was received. Since the Superstore data covers a period of time from 2019 to 2022, the date scaffold runs from 01/01/2019 to 31/12/2023.

                       

Create date scaffold in Google Sheets or Excel containing one record for all dates of interest
Join scaffold table on the Superstore data using a full outer join

The dashboard can be broken down into two parts, or worksheets: the top section, the actual calendar, and the order table at the bottom. Let’s start from the beginning by building out the calendar part.


Step 2: Creation of the calendar

 

As we want to display the days of the week in the columns and the week numbers in the rows, we drag the Scaffold Date field to the row and column shelves and change the data levels to display discrete WEEKDAY(Scaffold Date) and WEEK(Scaffold Date) accordingly. We also filter by the Scaffold Date to only show “This month”. To display the days of the month, drag the Scaffold Date field onto the Text Marks Card. Change the alignment to “Middle Center”. Lastly, change the Marks Type from Automatic to Circle and decrease the circle size.

 

Now we come to the interesting things: assigning different colours to the circles, depending on some conditions:

  • Today’s date
  • Selected dates
  • Dates with orders
  • Dates with no orders

 

The first thing to do on this worksheet is to create a set that allows us to create interaction with the calendar and the order table through a Set Action later on. For this, create a set from the field Scaffold Date and place it, together with the field Scaffold Date, onto the Details marks card.


Next, create the following calculation that determines to which group the circle in the view belongs and drag it onto Colour on the Marks card:

 
Calendar Bubble Color
IF [Scaffold Date] = TODAY() THEN "Today"
ELSEIF [Scaffold Date Set] THEN "Selected"
ELSEIF NOT ISNULL([Order ID]) THEN "Order"
ELSE "No order"
END


After these steps, the view should look like this:

 

 

Lastly, some clean up and formatting can be done to give our calendar a nice look:

  • Hide field labels for rows and columns
  • Hide row and column headers
  • Change date format of column headers to Abbreviation 
  • Change colours
      Order | Light blue | #ECF1FE
    ■  Today | Blue | #527AF6
    ■  Selected | Grey | #B3B7B8
      No order | White | #FFFFFF


With the first part of the dashboard finished, we can move on to creating the order table that appears when selecting a day in the calendar.


Step 3: Creation of the order table

 

There are five calculated fields required for the order table, so go ahead and create these fields first:

Field Name Field Syntax Explanation
Order ID Duplicate [Order ID] To display repeating row headers for the Order Date instead of grouped row headers
Last Name TRIM(SPLIT(Customer Name, “ “, 2)) To display only the customer’s last name in the order table
Shipping Status IIF(DATEDIFF('day', [Order Date], [Ship Date]) <= 3, "On Time", "Delayed") Indicates whether an order was shipped on time or delayed, based on the days between Order Date and Ship Date
Shipping On Time IF [Shipping Status] = "On Time" THEN "On Time" END Indicates whether a shipment was on time. This field is needed to assign a different text color in the table
Shipping Delayed IF [Shipping Status] = "Delayed" THEN "Delayed" END Indicates whether a shipment was delayed. This field is needed to assign a different text color in the table

 

Then, drag the Scaffold Date Set to the Filters shelf. Next, drag the following fields to the Rows shelf in the following order: Order ID Duplicate, Order Date, Order ID, Customer ID, Last Name, Ship Date. Change the date format of Order Date and Ship Date to Exact Date and then to Discrete.

 

Drag Shipping Status to Colour and Shape on the Marks card. As a shape I am using a rounded rectangle from Flaticon (download here) as a custom shape. Place Shipping Delayed and Shipping On Time on Label. Align the text in the middle center.

 

Finally, change the colours of the rounded rectangles and the labels.
  • Delayed
     Shape | Light red | #FDD8DA
      Text | Red | #F7646B
  • On Time
    Shape | Light blue | #ECF1FE
    Text | Blue |#3D71F5

Step 4: Bringing it all together

 

Create a new dashboard and set the size to 550 x 800 px. Place two vertical containers on the dashboard and drag the Calendar to the top one and the Order Detail sheet to the bottom container.


Next, we need to set up a Set Action to change the orders displayed in the table when selecting one or multiple dates from the calendar section:

Finally, all that is left to do are some formatting changes and the interactive orders calendar is ready!

You can also find the calendar dashboard on my Tableau Public profile here and download the workbook as a reference for creating your own version of the calendar.  

 

That's it. I hope this has been helpful to you and thanks for reading.

- Lucas

Author
Let's discuss your data challenges

Join our community of data enthusiasts

Get industry insights, expert tips and Biztory news sent straight to your inbox with our monthly newsletter.