Not actual size

Tableau Dynamic And Multi-Select Parameters

Dynamic Parameters are one of the most widely requested feature updates in Tableau followed immediately by Multi-Select Parameters. If these are functionality you need then it can seem like tableau has backed you into a corner with no way out.

However, there are a few tricks that you can employ in order to achieve the desired effect.

In this post we will explore how you can create the following.

The trick employed here only works with Tableau Server (Tableau Online or in this case Tableau Public) because we will be modifying URLs to achieve the pseudo dynamic and multi-select parameters. The 3 techniques we are going to use are:

  • Embed dashboards in other dashboards using a webpage
  • Pass values to a parameter in the URL
  • Use URL actions to update a URL with filtered field elements

We are going to end up creating 3 dashboards in 3 distinct workbooks. However, you only need two of the dashboards if you are forcing access through a link or embedded dashboard.

Dashboard 1: “Primary”:

This dashboard is nothing more than a webpage with the Parent dashboard embedded. The reason for this will be explained in detail at the end of this post.

Dashboard 2: “Parent”:

This dashboard is the driving force behind how this hack works. This is where we will be using quick filters to drive parameter values. This dashboard needs to fit in the webpage in the primary and it contains 4 key components.

  1. The title
  2. The quick filters
  3. An update button
  4. A Webpage that points to the child dashboard

Dashboard 3: “Child”

This dashboard is a standard dashboard with two exceptions.

  1. I needs to be sized to fit within the Parent dashboard’s webpage
  2. It should be driven by hidden parameters

Not actual size


 

Lets take a look at the steps it would take to build this set of dashboards.

  1. Design the Child dashboard including the parameter driven formula
    • Note that this is a rough build and final adjustments will come later
  2. Publish the rough Child dashboard
  3. Build the Parent dashboard
    • Note that this is a rough build and final adjustments will come later
  4. Publish the rough Parent Dashboard
  5. Build the Primary the size you want it consumed
  6. Publish the Primary (Final)
  7. Adjust the Parent Dashboard Size so that it will fit inside the Primary
    • This may take a few iterations to get right
  8. Do final clean up on the Parent Dashboard
  9. Publish the Parent Dashboard
  10. Adjust the Child Dashboard Size so that it will fit inside the Parent
    • This may take a few iterations to get right
  11. Do final clean up on the Child Dashboard
  12. Publish the Child Dashboard

Child

US vs Global Olympic Data

The dashboard is fairly simple so we will only discuss the formulas that drive the colors of the marks in the three vizs and the Sport filter to be applied.

The top two charts have the following string parsing formula on color:

IF LOWER([Country])= LOWER([CountryParam])
OR CONTAINS(LOWER([CountryParam]), LOWER([Country])+ “1”)
OR CONTAINS(LOWER([CountryParam]), “1”+LOWER([Country]))
THEN “Selected Countries”
ELSE “Other”
END

The reason for this is we want the Country field to be contained in the CountryParam parameter, and we are going to choose to set the delimiter in the parent to a “1” because we know that we it will not show up in the data.

This formula will create up to two categories of fields and thus break down our charts as appropriate.

The color of the bottom chart is driven by a similar formula except instead of dropping the selected countries into a single field, they are identified as their individual countries:

IF LOWER([Country])= LOWER([CountryParam])
OR CONTAINS(LOWER([CountryParam]), LOWER([Country])+ “1”)
OR CONTAINS(LOWER([CountryParam]), “1”+LOWER([Country]))
THEN [Country]
ELSE “Other”
END

We are also going to filter by the selected sports coming from the parent workbook because it will look more appealing to have our filters in a single line instead of one in each dashboard.

Because we are setting a series of variables to CountryParam parameter value we will need to treat our sport filter the same way we did our country selection. So we can use the formula:

IF LOWER([Sport])= LOWER([SportParam])
OR CONTAINS(LOWER([SportParam]), LOWER([Sport])+ “1”)
OR CONTAINS(LOWER([SportParam]), “1”+LOWER([Sport]))
THEN “Selected Sports”
ELSE “Other”
END

Now if we set “Selected Sports” to a global context filter we can set appropriate filtering throughout the child workbook.

Parent

Parent Dashboard

For ease of understanding I have put a yellow boarder around the child dashboard.

For this dashboard we can connect to  the same data set or a subset of it so that we have the relevant information for the quick filters. We can then create a simple viz that has a down arrow set up on the AVG([Number of Records]) because it will always be 1 or null. We can then call this sheet “Update” so that we know what it is for.

We will set the quick filters to be relevant values only so that we have them fully dynamic within the dashboard, in addition to when the data are refreshed.

The key in this dashboard is the URL action that we will be employing.

URL Action

As you can see we have created a URL action that runs on Select from our Update sheet. There are three important things to remember here.

  • We need to make sure to select “Allow Multiple Values” unless we only need to employ this technique for dynamic parameters.
  • The Item Delimiter needs to match what we set in the child workbook.
    • This will be the string between the values in the parameter
  • We need to make sure that we call the workbook with appropriate URL variable settings

This is the full URL:

https://public.tableau.com/views/OlymicSummaryChildWorkbook/Olympic?CountryParam=<FILTERVALUES(Country)>&:embed=y&:showVizHome=no&:showTabs=n&:display_count=n&SportParam=<FILTERVALUES(Sport)>&:render=false

Let’s take a closer look to see what we are calling.

  • https://public.tableau.com/views/OlymicSummaryChildWorkbook/Olympic
    • This is the base URL for the Child Workbook
  • ?CountryParam=<FILTERVALUES(Country)>
    • The Question mark indicates that we are going to start working with URL variables
    • Because there is no colon “:” Tableau knows to treat “CountryParam” as either a field or parameter in the destination workbook
    • <FILTERVALES(Country)> allows us to pass the list of filter values from the Country filter
  • &:embed=y
    • “&” indicates that we are going to add another URL parameter
    • :embed allows us to decide if we want to embed the view or show the entire webpage. We are embedding the Child dashboard in the Parent so we should set it to “y” (yes) as opposed to “n” (no).
  • &:showVizHome=no
    • showVizHome is a URL parameter you do not need to worry about if you are using Tableau Server, it is a necessary additional layer to embed on tableau public
  • &:showTabs=n
    • If there were multiple tabs in the Child workbook you can choose if you can see them or not by setting this variable y/n
  • &:display_count=n
    • This allows you to decide if the count of the number of views is displayed in your embed
  • &SportParam=<FILTERVALUES(Sport)>
    • This will pass the filtered list of sports to the SportParam
  • &:render=false
    • This will force the dashboard to render in the server and we will discuss it’s importance when we look at the Primary.

Note: that the order of these parameters does not matter accented by the intermixing of them above. However, for ease of use it is typical to put your field and parameter URL parameters at the end.

Primary/Embed/Link

Primary Dashboard

Now you may be confused about why we need the Primary.

The reason speaks to the same reason we set the dashboard to render on the server side instead of allowing it to render on the client side (in the web browser) for the call to the Child dashboard. The problem that we are avoiding here is the two ways that dashboards can be accessed. There is the typical URL which most of us are familiar with and then there is HTML canvas elements.

When you are using client side rendering you are forcing HTML canvas elements which typically would be a good thing, however, in this case instead of creating a string to be put into the parameter, it tries to pass a list that work with filters. By calling the Parent dashboard with :render=false you are forcing the dashboard to call a URL that will tell the server what to do.

So this leads the the second level of embedding. You can see here (indicated by the dual level tableau public forced toolbar that we are calling the Parent, which is in turn calling the Child.

When you expect your end users to navigate to the dashboard on Tableau Server you will need to add a Primary dashboard for them to access. However, if you intend to provide them a link, or give them embedded access to the dashboard with you will be able to just set the render value in the link there.

For example this link will open the parent dashboard with the desired settings.

Let me know what you think.

Michael Davis

4 thoughts on “Tableau Dynamic And Multi-Select Parameters”

  1. Excellent beat ! I wish to apprentice while you amend your web site, how can I subscribe for a blog web site?
    The account aided me a acceptable deal. I had been tiny bit acquainted of this your broadcast offered bright clear idea

  2. I do trust all the ideas you have offered in your post.
    They are very convincing and can certainly work.
    Nonetheless, the posts are too quick for beginners.
    May you please extend them a little from subsequent time? Thanks for
    the post.

Leave a Reply

Your email address will not be published. Required fields are marked *