Filter Tableau data using URL parameters
- Robin Hurni
- Aug 16, 2020
- 3 min read
Updated: Sep 26, 2020
If you have ever used an online Tableau dashboard containing lots of data, you know the struggle of having to apply many filters every time you connect on a dashboard and the time it takes. ⌛️
If you want to always see the dashboard using the same filters, you can set up a custom views, but you might not always wanna look at the same parameters (e.g. you want to see a different product category or the performance of a different sales person). This is where the URL parameters get very handy! 💡
Tableau Server & URL
Let me start with a bit of background around Tableau servers and how the URL are built. By default, a Tableau dashboard/view has the following URL:
TABLEAU SERVER (single or multi environments)
-------------------
https://<server>/#/views/<dashboard>/<view> OR
https://<server>/#/site/<site>/views/<dashboard>/<view>
TABLEAU PUBLIC
-------------------https://public.tableau.com/profile/<username>#!/vizhome/<dashboard>/<view>
When you load a view on Tableau, it shows the filters as they were set when the dashboard was published. Using URL parameters, it is possible to change what is loaded.
Tableau Filters
Parameters in a URL are passed using a question mark (?) sign at the end of the address. http://supermarket.com/prices?product=vegetables It is possible to enter several values per parameter,by separating them with a comma (,). http://supermarket.com/prices?product=vegetables,coffee,milk You can combine several parameters using ampersands (&). http://supermarket.com/prices?product=vegetables&category=salads Some characters are not accepted on a URL such as the space character. Those characters should be URL encoded. The encoded character for the space is %20. You can find the list of codes on the W3 Schools website. http://supermarket.com/prices?brand=Mountain%20Dew Try it Yourself! It is now time for your to try! ⚒️ I created a dashboard using the Superstore data sample and published it on my Tableau Public page. Try to update the categories, segments and manufacturers using the URL parameters instead of the filters in the right hand side of the screen. Here is an example where I applied different filters directly in the URL:

Sales Records for the Office Supplies category, selecting only Consumer and Home Office segments and a few brands.To create this view, I used the following URL (I broke it down in several lines for better visibility):
https://public.tableau.com/profile/robin.hurni#!/vizhome/Sales_15967136900420/Sales
?Manufacturer=3M,Anker,Array,AT%26T
&Category=Office%20Supplies
&Segment=Home%20Office,Consumer
I started by selecting 4 manufacturers that I separated with commas. AT&T contains a special characters that I encoded using %26. Then I selected two categories (Office Supplies has a %20 encoded character to replace the space) and finally I selected two segments. Easy no? 😄
Tableau Parameters
URLs parameters don’t work solely with filters but also with Tableau parameters. In the example below, I have a Tableau dashboard that shows the evolution of the Marathon world record. This dashboard has a parameter than can be switched to Half-Marathon to see the evolution of the Half-Marathon world record. 🏃 We just need to add the following parameter at the end of the URL to directly land on the Half-Marathon World Record evolution rather than the Marathon one. ?Race=Half-Marathon

Why is it useful?
You might wonder why this could be useful… 🤔 Indeed, entering all the parameters within the URL could be more time-consuming than applying the filters directly on the dashboard.
So let me give you an example: you are the sales director of a company that employs 100 salesmen and you want them to have access to their sales results without seeing the results of the other salesmen. What you can do is create a dashboard that does not have any filter on the interface and only apply the filters using an ID that is encoded in the URL. When the salesmen will use their own URL, they will directly (and only!) see their own results. 📝

More information
This article aims to give a simple example of how to use parameters in URL for Tableau dashboards published either on Tableau Server or Tableau Public. You can go further in the filtering by looking at the documentation provided by Tableau.
Feedback
Thank you for reading through the end of this article. Please let me know if you have some examples of how you used it and how it helped you save some time! 👍
Comentarios