After working in Seattle with the wonderful folks at Tableau for the last week I was reminded of the incredible significance of Tableau Server. I have found that we often look at Tableau Server as a self –service tool. We see it as a tool which users must not only log into in order to view their relevant dashboards, but also interact with to filter the data which is pertinent to them.
In November I’ll be speaking at the Tableau Customer Conference in San Diego, CA on the importance of leveraging tabcmd in the server environment. While Tabcmd is a robust tool which allows administrators to automate Tableau server in many ways, perhaps the most relevant to business users is the ability to automate the sharing of their dashboards.
Using tabcmd to automate our dashboard distribution can seem daunting at first, but let’s break it up into some simple steps in order to make it easy and maybe even a little fun!
Once tabcmd is installed we need to write a batch file in order to automate the pdf download. Don’t worry if you are not familiar with writing command line code. All of the Tableau-based commands are noted here, and the Windows-based commands are listed out fairly well in Wikipedia. I will show you how to add some cool windows commands after your Tableau script later so you have an idea about how incorporate both of them into a single script.
The batch file must start with a login to the server. Tableau will always require a login to the server with a user account which has access to the dashboards we would like to distribute. Let’s break up that code:
The first command is the tabcmd command which tells windows this is a Tableau server command. We then define the server location which we are logging into by using “–s” or “–server”. We then use our login name preceded by “–u” or “–user”. Finally you’ll see that we have defined the password in the same manner, but instead of typing our password directly, we have referred tabcmd to a file location with our password typed into that file. The file must sit in the same location as the batch file which should reside in the “Command Line Utility” folder if you installed to the default location. The password file simply adds an additional layer of security to our batch file.
Now that we are logged into our server, we can start executing our commands.
Our command line will look like this:
The first command we execute is the “Get” command to Tableau server. Essentially we are telling Tableau server to go to the URL of the dashboard we want and “get” a PDF copy of that dashboard. It will automatically get it, and download it to the “Command Line Utility” folder on the local machine.
You may also notice that I have added a ?RegionParameter=West designation to our URL . This designation allows me to leverage a parameter in my dashboard named “RegionParameter”. Adding it to the URL allows me to filter each get command differently so each downloaded PDF will be specifically relevant to the users for which they are intended. For example the first URL above will create a view for my Western regional manager, but I just need to add a second line and change the filter to South I will have one PDF for my Southern manager and one for my Western manager. I have also added a command to give my PDF a specific filename (we’ll see why later) and a timeout counter in case my server becomes unresponsive.
I’ll then logout of tabcmd by adding the command “tabcmd logout” at the end of my script. That is all of the Tableau command lines I need to write. Just remember to save the file with a .bat extension. The PDFs are downloaded onto my local machine and I can send them out manually via email to each user.
However if I wanted to take the automation a step further I could add a few more lines in the same batch file to move them to a networked location or a mapped drive. This next section of code does that for me. In this specific case tabcmd was installed to c:tabcmd instead of the “command line utility” folder.
I just added a “move” command which tells Windows to move the files from one location to the location which follows. Since I wanted old files to be overwritten by the new ones I chose the “/Y” switch with tells Windows to overwrite the old files for me.
You can even take it a step farther and use Windows task scheduler to automate the execution of your batch script! Fun! That’s as easy as it is to automate your dashboards to those folks who do not have access to Tableau server. While not the optimal solution, I have found it helps those who do not always have the time or opportunity to log into Tableau Server.