top of page
Search
  • Writer's pictureJames Goodall

Tableau Bitesize: Passing Parameters Values in a URL

Updated: Jan 24, 2023

This may be old news to some people, but I’ve recently discovered that it’s possible to include parameter and filter values in a URL to a tableau workbook hosted on e.g. Tableau Server or Public, enabling us to tailor views specifically to groups of people or individuals


My scenario was that I had built a workbook looking at data for the 11 different Local Authority Districts in Surrey. My customer was putting together 11 different web pages containing information for each of these areas and wanted to embed the workbook on these pages, but with the view set to the area in question



Initially I thought I’d have to duplicate all of my worksheets 11 times and create 11 different filtered dashboards for this (a lot of effort and a lot more if the requirements change!)


However, using the method outlined below, we can just have a single dashboard and pass a parameter value (that is used as a filter and sets a colour) via the embed URL



This could also be used if you just want to share a link to someone without the need to tell them how to filter / change the parameter


I will go through how to build a dashboard and set this up using some census 2021 population data and a shapefile – both attached below:


census_2021_population
.csv
Download CSV • 483B

surrey_lads
.zip
Download ZIP • 345KB

Firstly, connect to the data sources, and join them together on ‘Code’ = ‘Lad17Cd’



Create a map by double clicking on ‘Geometry’ field, dragging the ‘Name’ field onto the ‘Detail’ mark. I have also removed the default background layers



Next, create a parameter from the ‘Name’ field and call this ‘Name_Parameter’ (make sure you don’t include a space in the parameter title or this won’t work)​​​​​​​



Create a calculated field called ‘Name Highlight’ as follows:



[Name] = [Name_Parameter]


Drag this field onto the ‘Colour’ mark and set the colours to your choosing



Create a new sheet called ‘All’, drag the SUM of ‘All’ onto the ‘Label’ mark and format to your choosing



Create another sheet called ‘Breakdown by Sex’ and make a bar chart with ‘Measure Values’ on the ‘Rows’ shelf and ‘Measure Values’ on the ‘Columns’ shelf, including only the ‘Males’ and ‘Females’ measures then format to your choosing



Finally, create one last sheet called ‘Title’. Drag the ‘Name’ field onto the ‘Label’ mark and add the text ‘This dashboard shows population information for <Name>, taken from the 2021 Census’



Drag the ‘Name Highlight’ calculated field onto the ‘Filters’ card, selecting ‘True’, then right click and choose ‘Apply to Worksheet -> Selected Worksheets’



Apply it to the ‘Breakdown by Sex’, ‘All’ and ‘Title’ sheets



Create a dashboard with these 4 sheets and format to your choosing



I have also added a Parameter Action to allow users to click on an area on the map to filter the other charts



I will then publish this to Tableau Public (or Server) and get the sharing URL – in this case it is https://public.tableau.com/views/TableauBitesize-PassingParametersInURL/PassingParametersinURL


I can then add in values for the ‘Name’ parameter in the URL to default to that value when the link is followed (or embedded). This is done by including a question mark (?) at the end followed by ‘Parameters.<Name of Parameter>=Value of Parameter’


So if I wanted to pass in ‘Guildford’ as the parameter value, it would be ?Parameters.Name_Parameter=Guildford


Making the full URL:




NB: the above is embedded as an iframe and so has the following embed code:


<iframe src="https://public.tableau.com/views/TableauBitesize-PassingParametersInURL/PassingParametersinURL?:display_count=n&amp;:showVizHome=no&amp;Parameters.Name_Parameter=Guildford" width="800" height="600"></iframe>


--------------------------------------------------


If you are passing in a parameter with special characters (e.g. spaces), make sure you replace these with the relevant HTML URL Encoding value


For a space this is %20 so if I wanted to pass the value ‘Epsom and Ewell’ it would be ?Parameters.Name_Parameter=Epsom%20and%20Ewell




And there we have it - both of the above embedded dashboards are linking to the same dashboard, but by passing in the parameter value within the URL, it allows us more freedom for customisation for our users


As mentioned at the start, it is also possible to pass in Filter values via a URL, but maybe that's for another day...

709 views0 comments
bottom of page