When analyzing any data over time, it is important to understand the seasonality or natural ebbs and flows of the data. For many businesses, these patterns in the data can be seen all the way down to the individual days of the week. Occasionally, it may be important to toggle off certain weekdays to get a clear picture or story within an analysis. In this blog, I will show you how to toggle weekends on and off from an analysis. As a bonus, I will also show you how to build a calendar view and parameterize the toggle to switch between different views in Tableau.

How to Make an Integrated Toggle Switch in Tableau

How to Toggle Weekends On and Off a Calendar in Tableau

View / Interact / Download

 

How to Create a Calendar View in Tableau

To start things off, let’s set up a simple calendar view so we can see the toggle working. First, I am going to connect to the Sample – Superstore dataset and drag Weekday of Order Date to the Columns Shelf.

New to Playfair Data?

Watch our 90-second intro video and receive tips on making your data usable.
 
Watch Video

Next, I will drag Week of Order Date to the Rows Shelf. These are both discrete date parts of Order Date. The easiest way to get them onto the view is to right-click and drag them to the corresponding shelf. This will open a selection screen where you can choose which date part you want to use.

First step to creating a calendar in Tableau

Create a free account, or login.

Unlock this tutorial and hundreds of other free visual analytics resources from our expert team.

Already have an account? Sign In

Name
Password
This field is for validation purposes and should be left unchanged.

Explore unlimited access to all offerings.

See membership options.

To create the calendar view, we will now want to filter on a specific month. To do this I will drag Order Date to the Filters Shelf, choose Month / Year, and click Next.

Filter Field Order Date

In the next menu I will select November 2020 and click OK.

Filtering month and year from the calendar in Tableau

With our filter in place, our calendar view is starting to take shape.

With the filter in place, the calendar view is starting to take shape.

Now I will right-click and drag Order Date to the Label property of the Marks Card. Then select DAY(Order Date) from the menu and click OK.

Select Day(Order Date) from the menu

Next, I am going to drag Sales to the Color property of the Marks Card and change the mark type to Square.

Drag Sales to the Color property of the Marks Card and change the Mark type to Square

To add a personal touch, I will right-click on the Day of Order Date pill and align the labels to the top right. I will also right-click on Week of Order Date on the Rows Shelf and hide the header. Last, I will expand the view by clicking and dragging the bottom of the chart and update my color palette.

Format the calendar in Tableau

 

How to Create a Weekend Toggle In Tableau

Now that our view is set up and we can clearly see the weekdays displayed, lets create a toggle that will NULL weekends. To begin, let’s create a new parameter by right-clicking in any blank space within the Data pane and selecting Create Parameter. In the dialog that appears, I will change the title to Weekday Toggle Parameter, change the data type to Boolean, and click OK.

Weekday toggle parameter for the calendar in Tableau

This parameter will act as our toggle later on, but first we need to create a way for the user to assign which weekdays to toggle on and off. To do this I am going to right-click on Order Date, hover over Create, then select Custom Date. In the dialog that appears I will click the Detail dropdown and select Weekdays; then click OK.

Create Custom Date

Now I will right-click on the new custom date calculated field, hover over Create, and choose Set.

Create a set to toggle weekends off a calendar in Tableau

In the Create Set dialog, I will add Sunday and Saturday in my set, select the Exclude button, then click OK.

Order Date Weekdays To Remove Set

Now I will create one last set following the same steps, except this time I will include all weekdays in the set. The final setup should look like this:

Select all days in the Set

An Introduction to Tableau Sets

To bring it all the together I am going to create a calculated field by right-clicking in any blank space on the Data pane and selecting Create Calculated Field. I will enter the following calculation then click OK.

IIF([Weekday Toggle Parameter]=TRUE,[Order Date Weekdays To Remove],[Order Date All Weekdays])

Weekend Toggle calculation

Last, we will drag our new calculation to the Filters Shelf, select True, and click OK. This completes our calendar view sheet and the initial setup.

 

Setting Up A Toggle Using Tableau Parameter Actions

Now we are ready to implement the toggle sheet. First, we need to create a new sheet that will be used for the toggle on the dashboard. I’m going to open a new sheet by clicking the New Sheet icon at the bottom of the Authoring interface. Next, I’ll create our last calculated field by right-clicking in any blank space in the Data pane, selecting Create Calculated Field, entering the following calculation, and clicking OK.

IIF([Weekday Toggle Parameter]=TRUE,FALSE,TRUE)

Toggle calculation

In our blank sheet, I will change the mark type to Shape, then drag the new Toggle calculated field to the Shape property of the Marks Card. For our toggle shape I will load in a toggle image for both an active and inactive state or for when our parameter is True versus False. To do this, I loaded some custom images to my repository but the sky is the limit for this step, so get creative!

The final step is to add both sheets to a dashboard and set up a dashboard action. To do so, I will click the New Dashboard icon at the bottom of the Authoring interface and drag both sheets onto the view. With both sheets in the view, I am going to click Dashboard in the top navigation and select Actions. From the menu that appears, I will click Add Action, then Change Parameter. In the next dialog screen, I am going to select our toggle sheet as the source, change the target parameter to the Weekday Toggle Parameter, and choose our Toggle calculated field as the value to pass. Last, I will ensure the action runs on Select, click OK, and click OK again. The final setup should look like this.

Toggle parameter action

How to Use Tableau Parameter Dashboard Actions

Now if you click on the toggle image on the dashboard, we will see Saturday and Sunday get excluded from the view. One last tip; If you want to allow your user to choose which weekdays to remove, click on the calendar view sheet on the dashboard, then click on the arrow that appears within the gray border.

Make your data more usable with our free newsletter.

Get monthly tips and tutorials:

From the menu, hover over Sets, and click the set you set up that excludes certain weekdays. This will show the user the list of weekdays that will be excluded when your toggle is True.

How to Toggle Weekends On and Off a Calendar in Tableau

I’ve shown you how to toggle weekends on and off from a literal calendar view in Tableau, but this same technique can be applied to any chart type and/or complete dashboards!

Until next time,
Ethan Lang
Director, Analytics Engineering
[email protected]

Become a member

Get access to this related video & more!

Become a Member

Related Content

Ryan Sleeper

Toggle On the Fun with 3 Techniques and 3 Practical Applications In this exclusive Playfair+ webinar, Ryan shares techniques for…