Building calendars in Tableau has been quite a popular trend as of late. You may have seen Autumns content tracker, and Lindsay’s VOTD customised calendar. Both so elegant in design.
Well with that in mind, I’m delighted to have Chris Westlake joins the blog today to talk through how to create a calendar in Tableau. Chris faced the challenge to upgrade one of our accounts calendars and made some major improvements too it, so I’m glad he is able to share a sanitised version with us today. All the resources (dataset and copy of the dashboard) can be found at the links at the top of the page under the title. I hope that you can easy implement this calendar style into your organisation.
Chris, over to you.
CW: I recently started a new job, and one of my first tasks was to improve the aesthetics of an events calendar. I was amazed by some of the techniques used in the workbook already, but also added some features of my own. My immediate thought looking at the workbook was to use map layers to achieve the desired result in one sheet, but sometimes business presents us with restrictions that we can’t control. This tutorial will create the same calendar view, this time using data relating to birthdays and anniversaries in my family that I am simply terrible at remembering!
Step 1 – Data
You’ll need two tables in your data source for this
This is the events that you want to show on your calendar, with the dates. In this example we have 3 fields in here: Event Date, Event, Person
- Calendar padding
This is simply a list of all the days in the year so that each day will feature in the calendar
These tables can be joined together via a relationship on the date field
Step 2 – Basic calendar
We are going to use two worksheets in this tutorial: one for the background calendar layout, and one featuring text of events.
The first step is to create a filter so that the view only displays one month at a time. To do this, we will create a calculated field using Event Date that returns the date of the first of the month of each event which ensures all events in the given month will still be in the view.
Exact Date Param Date
MAKEDATE(DATEPART(‘year’,[Event Date]),DATEPART(‘month’,[Event Date]),1)
Next, we create a date parameter which will populate with the values from our calculated field each time the workbook opens (I find it strange that no one in my family has a birthday or anniversary later in the year than September, but some things you can’t control!)
Finally, we can create the calculation to be used as a filter. We add this to Filters and set it to be TRUE
Date = Param Date
MAKEDATE(DATEPART(‘year’,[Date]),DATEPART(‘month’,[Date]),1) = [Month Parameter]
With that out of the way, we can start building the calendar view. Bring Date onto Columns at weekday level, and onto Rows at week number level. To give us maximum flexibility when building the background of the calendar, we are going to add a dummy field onto Rows. To do this, double click on the rows shelf and simply type a zero (0). Set this to be a dimension instead of a measure and you will see the marks card will have chosen to show this as a gantt chart automatically. Your sheet should look as follows:
To create the boxes, we need these straight lines to grow. Increasing the size with the size pill makes them wider, but not taller. To achieve this, double click below detail on the marks card and type a 1. The resulting sum(1) pill can be moved onto size and will give us some height. Manually change the axis of our dummy pill on rows to range from 0 to 1 and you will see something recognisable as a calendar. After adding date numbers, changing the colour and some other formatting, we now have the following:
Obviously in a normal calendar, the days of the week appear at the top. To achieve this, navigate to Analysis > Table Layout > Advanced and deselect “Show innermost level at bottom of view when there is a vertical axis.
At this step I have also added another dummy pill to the columns shelf to give a little padding between the days of the week and the body of the calendar. We can also add the auto-generated Events (Count) field onto colour, formatting it to highlight days that have events on them. The sheet now looks like this and we have the basic outline of a calendar.
Step 3 – Banding on the calendar
We are now ready to add the darker band across the top of each day to help the rows stand out from one another. To do this, duplicate the dummy 0 pill and set to be a dual axis. On the marks card for the duplicated version, remove the text as we don’t need this twice, and change the colours to be a shade darker so they stand out.
When you change the colours you will notice it changes them for both axes. To avoid this, double click on the colour pill for the second axis and add 0.1 (so it reads COUNT([Events])+0.1). This creates a second colour legend that you will be able to change as distinct from the first.
The second axis now covers the whole of the first because they have the same size element. Double click on the sum(1) pill and change it to sum(0.2). The 0.2 is right for the text size I have used – you may need to adjust it according to your own sizing. You can now see something close to what we want, but the band is at the bottom of each box instead of the top. This is because a gantt chart will always start at 0 and fill up to the size we have specified. To fix it, simply reverse the duplicated axis. Hiding the axis labels, we have a two toned calendar with the top portion of each day in a slightly darker colour than the rest.
Step 4 – Text layover
Adding text to appear where we want it is tricky on this same page, especially where we have multiple events happening on the same day. For this reason, we are going to create another sheet with just the event details to float over the top of the first sheet in our dashboard. There is a lot of crossover here with building the calendar layout so I will simply highlight some differences.
Difference 1: Instead of Date on the marks card we are using Event Date so that the tooltip will only show for days with events on.
Difference 2: The discrete WEEKDAY(Date) pill has become a continuous ISOWEEKDAY(Date) pill. It is continuous to make lining up the sheets easier when we come to building the dashboard, and ISOWEEKDAY so that the week starts counting on a Monday instead of a Sunday.
Difference 3: In order to show the full month, we will need to show empty rows and columns. The filter has been added to context so that the rows are filtered before empty ones are shown in Tableau’s order of operations.
Difference 4: The index() pill on rows has been added so that when there are multiple events on one day they appear in a column rather than on top of one another.
Step 5 – Dashboard creation
We now have our sheets built and are ready to combine them into a dashboard. Add a title and don’t forget to add the date parameter so that you can change which month is displayed!
Thanks Chris for pulling this together. It feels like a very robust solution and love the ability to highlight specific dates in the calendar and the nifty trick of reversing the axis for the red banner across the top. Do tag Chris in your own creations if you end up using his calendar view.