Back to Blog

Creating Dynamic Titles Based on Multiple Filters

Creating Dynamic Titles Based on Multiple Filters

Tableau has created a guide for creating dynamic titles based on a single filter (CreatingDynamic Titles Based on Filters | Tableau Software), but what if you wanted the title to work across multiple filters?

This article gives you step by step instructions on how to create a dynamic title that will work across multiple filters.

Scenario

Imagine you have a dataset that can be filtered by team, division, and conference, for example an NFL dataset with the following fields: number of playoff wins, number of titles, and revenue.

You want to create a label worksheet that, when the dataset is filtered, shows which filters are currently active. For example, like this (note these are not real data):

You might ask, how could this be helpful? Don’t you already have the filters visible to show you what is selected? Well, there are situations where it may not be ideal for the filters to be visible. For example, imagine you were generating PDF reports of dashboard using Tabcmd that would be automatically emailed to each team owner, in this case, a label for the table would look better (and allow for easier interpretation of the data) than showing all three filters of the dashboard. Having a label would still be helpful and even look better, even if you already have the filters visible, as worksheets allow more formatting options than do the filters.

Preparation

Before implementation, it is helpful to write out exactly what you want the label to show based on which filters are selected. For example, what if the conference and team filters are selected? You must consider how individuals will use the filters. In the case above, an individual might first select a conference and then skip the division filter and go straight to the team. They want to see the specific team; therefore, you may want the team filter to always ‘override’ the conference filter in the label. You may also want the division filter to always ‘override’ the conference filter.

Therefore, you first need to map out what you want the label to show based on all possible filter combinations, THEN, you can start building out ‘logic statements’ that can be later translated into calculated fields in Tableau:

For the scenario above, here are the logic statements:

Logic Statement 1:

IF [Conference] = 1, THEN [Conference] ELSE "NFL" - in other words, if the Conference field has been filtered down to one record, then set as that record, otherwise, set as “NFL”.

Logic Statement 2:

[Conference] + [Division] – concatenate Conference and Division (e.g., AFC North)

Logic Statement 3:

IF [Team] = 1, THEN "" ELSE [Logic Statement 2]

Logic Statement 4:

IF [Team] = 1, THEN "" ELSE [Division]

Logic Statement 5:

IF [Conference] = 1 AND [Division] = 1 THEN [Logic Statement 3] ELSEIF [Team] = 1 THEN [Logic Statement 4] ELSE [Logic Statement 1]

Logic Statement 6:

IF [Team] = 1, THEN [Team], ELSE [Logic Statement 5]

Instructions

Step 1: Create calculated fields.

Now that you have mapped out your logic, it is time to create calculated fields in Tableau and set up the worksheet that will function as the label. Each logic statement should be its own calculated field:

1. IF {COUNTD([Conference])} = 1 THEN [Conference] ELSE "NFL" END

2. [Conference] + " " + [Division]

3. IF {COUNTD([Team])} = 1 THEN "" ELSE [Logic statement 2] END

4. IF {COUNTD([Team])} = 1 THEN [Division] ELSE "" END

5. IF {COUNTD([Conference])} = 1 AND {COUNTD([Division])} = 1 THEN [Logic statement 3] ELSEIF {COUNTD([Team])} = 1 THEN [Logic statement 4] ELSE [Logic statement 1] END

6. IF {COUNTD(Team)} = 1 THEN [Team] ELSE [Logic statement 5] END

Step 2: Drag the last logic statement to ‘Text’ in the Mark card and format the worksheet as needed.

Step 3: Add the appropriate fields into the Filter card (In our cause Conference, Division, and Team)

Step 4: Add all the filters to context.

Step 5: Select to show “Only Relevant Values.”

And you are done. Now you can place the worksheet on the dashboard, and it will dynamically change based on the filters!

Subscribe to our newsletter

Want to stay up to date on our latest articles and news? Subscribe to
our newsletter below.

Thanks for joining our newsletter.
Oops! Something went wrong.