Using Tableau Public Templates Efficiently

Jan 12, 2022

Klaus Schulte

Tableau Public is an incredible resource. 2M authors who have published more than 5M visualizations and billions of views, these are the latest figures I’ve heart last year. That’s stunning. I personally also made my first steps with Tableau on Tableau Public and used it ever since to share my own visualizations with the community. I’ve also taken lots of inspiration from the visualizations on Public, and learnt a ton, when I downloaded and reverse engineered the workbooks.

That’s the learning part of Tableau Public, which cannot be valued highly enough.

However, there is one thing, that I’ve always found quite difficult with Tableau Public:

It’s actually not that easy to take a workbook from Tableau Public, and use it with your own data. Most of the time you’ll take inspiration from Tableau Public, and recreate a visualization from scratch. Not very efficient. Even with the template workbooks available, it often needs blogs with accompanying Excel files or Google sheets, to update the workbooks, like described in this blog by Ken Flerlage or this one by Alexander Mou on the same topic (updating Sankey Templates) or this one by myself.

In this blog, I’ll describe a generic approach to connect your data to any (suitable) workbook available as a download on Tableau Public. Yeah 🤓!

Using Tableau Public Templates Efficiently

Here’s the generic approach:

1. Download a Workbook (e. g. search for “Templates” on Tableau Public)

I’m using Ken’s Sankey Template Format 2 to demonstrate my approach here.

2. Unzip the .twbx File

A .twbx file is basically just a .zip file. Easiest method to unzip a .twbx is to change the extension to .zip, then just about anything can open it.

You’ll find a .twb and a .hyper file in the .zip.

3. Open the Workbook and add a new data source by connecting to the .hyper-File stored in the .twbx:

4. Replace the original data source

Go to Data -> Replace Data Source… and replace the current data source (“Sankey”) with the one you’ve connected to in Step 3 (“excel-direct.42458 Extract”).

Close the original data source (“Sankey”), we don’t need it anymore.

5. Fix broken fields

It can happen, that field names differ in the .hyper file you’ve connected to and calculations break. In this case, replace references to the correct fields in the .hyper:

Same has to be done for t (Model) to T in this example.

6. Edit data source and connect to your data

Edit the data source you just created from the hyper file, add in a new connection to your data, and relate the two by creating relationship calculations for both tables.

In case you’ve never done this before, click here to create the relationship calculation. Then just type 1 into the editor.

Click "Create Relationship Calculation" in the Relationship Set Up menu

7. Replace References

Last step is to replace the references from the original to your own data. In my example, Step 1 will be Customer Segments, and Step 2 will be Product Categories. And Size will be replaced by Sales.

Use the Replace Reference Feature for each dimension and measure used in the view.

And that’s it!

The final product: A sankey transforming Sales by Segment to Sales by Category.

Things that can go wrong

FIeld name confusion

When using my approach with Jeff Shaffer’s Multi-Level Sankey Template, I came across this issue:

Non-unique field names after replacing the data source

Note that there is one field “t (Model)” in the original workbook, and one calculated field “T”.

In the .hyper file saved in the .twbx, “t (Model)” is named “T”

t (model) is named "T" in the new data source

I had to rename the calculated field “T” to “T (calc)” (or similar) before replacing the data source to not run into issues here.

Use of Relationships in the data model

When using the approach with Ken’s Coxcomb Template I came across this challenge:

Two separate tables in the hyper file. Build/Guess the relation between those two tables.

Ken uses the Relationship feature in his data model, and the tables are stored separately in the hyper file. I had to guess the relationship between those two tables, but like most of the time with these kind of chart types, it’s a relationship (or join) on 1=1.

Using the method in production

This method is quick and super simple.

If you’re designing for production, you will want to put the workbook or datasource on an update schedule. Please consider the following options in case that’s relevant for you:

Store data models on an accessible file share

When published to Tableau Server, a data refresh attempt will give an error when the .hyper file is stored locally on your computer. Make sure that the file is located on a file share, that is accessible for the server.

This applies both to the case when you publish and refresh the data source separately and to the case when you want to refresh the workbook only.

Store data models in a database

The first option will be a bit of a pain for people who are connecting to a database and, therefore, don’t want to mess with the steps needed to do a file-based data source refresh.

In this case, I’d recommend uploading the .hyper file to your database after you’ve unzipped the .twbx (after step 2).

In this example I use Tableau Prep to bring the .hyper file to my Google BigQuery. Uploading to a database will require some variable renaming in case blanks are used as variable names.

After you’ve uploaded the data model, you can continue with step 3 and use this method as described, now using tables from your database only.

This way you can collect all the data models for the different chart types in one place and have it accessible for everyone who wants to use it.

Conclusion

I tried this approach with several templates available. It was super fun and I’ve never been able to plug my own data to templates that fast: the steps I’ve described above can be done in less than five minutes!

A big PLEASE to all creators of templates: If you want people to use your templates with this method, please make sure, that all the variables needed are calculated in the workbook. I’m already curating a list of templates we can easily use with this method. This list will eventually end in something like a catalog, which will for sure help the community to use this kind of complicated chart types more efficiently. If you have successfully tried this approach with your template, please let me know and I will add your template to my list.

One final thing that is close to my heart:

Please make sure to pay attribution to the creator of the original content when you use their work!

I hope you find this as useful as I do. Please let me know your feedback!

You’ll find me on Twitter (@ProfDrKSchulte) or leave a comment below.

P.S.: Big thanks to Ken Flerlage for his valuable feedback (as always) along the way.