Your Tableau Public Statistics

First off, this was a 100% team effort and without Josh, Rodrigo, Amar and Ken (and probably a few other folks along the way as well) it wouldn’t have happened. Apologies if iI missed your contribution  but searching old Twitter feeds isn’t the easiest task! My role was honestly very limited short of testing and an idea. More proof that the Tableau Community is one of the most collaborative on the planet.

So, you want to see your Tableau Public stats, and build a viz about your vizzes? Very meta of you, and here is how you do it.

Step 1: The URL

https://public.tableau.com/profile/api/YOUR.USER.PROFILE/workbooks?count=300&index=0#

It was Rodrigo, by way of the good folks at Import.io, who first shared this API to access your Tableau Public stats. What the API does is spit out a JSON dataset of your Tableau Public Profile, which is pretty cool. Simply replace the YOUR.USER.PROFILE with you profile reference (it comes after the word profile in the Tableau Public URL when viewing your profile

This is the resulting JSON that you get.

Step 2: The Script

You can save it as a JSON and use it to create a viz, but what if you want to have this refresh regularly? Next up was Josh who found a script that we could use in Google Drive to populate the JSON to a Spreadsheet when the spreadsheet opened. It’s called ImportJSON.gs

Really cool, but the timing of it was causing an issue with the viz at time as the sheet may have not refreshed and you’d get a blank viz. I made the recommendation that we come up with a script to copy the data to a static sheet and use that one in the viz, but I’m not a strong coder, so Ken stepped in and came up with this: (don’t worry, it’s in the linked document above already)

}
function sheetCopy() {
var sss = SpreadsheetApp.getActiveSpreadsheet();
var ss = sss.getSheetByName(‘Import’);
var range = ss.getRange(‘A:AT’);
var data = range.getValues();
var ts = sss.getSheetByName(‘Static’);
ts.getRange(‘A:AT’).setValues(data);
}

Step 3: Putting it all together

Create a Google Sheet with two tabs, one called Import and one called Static, and place the following in Cell A1 of the Import Tab:

‘=ImportJSON(“https://public.tableau.com/profile/api/YOUR.TABLEAU.PROFILE/workbooks?count=300&index=0#”, “”, “noInherit”)

If you happen to have more than 300 vizzes in your profile, simply add a second URL in A2 and start the COUNT parameter at 301

Next, go to Tool > Script Editor and paste in the code from the file above.

Next, in the script editor window, go to Edit > Current Project’s Triggers and set the recalculateAll to what ever interval you choose. If you have it refreshing and it fails, you can set up notifications to receive emails summarizing the failures.

As always, you will need to agree to some terms and conditions with Google as you use this script and API calls

Give it a few minutes to run and populate your Static sheet, then open it and double-check that you are actually seeing the data.

Finally, get the URL of your Google Sheet and use the Static worksheet as your data source and create your dashboard. There are lots of cool statistics so explore the data and find some cool insights on your portfolio!

Leave a Reply

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