Automating Tableau Prep for Windows

Jeff Parks
3 min readJan 10, 2020

Tableau — Intermediate

[Apple user? Click here for the Mac version of this article!]

If you’re working in the Tableau environment for your data analysis and visualizations, then Tableau Prep is a lifesaver for building complex data transformations and performing that crucial ETL (Extract, Transform Load) function in your workflow.

Once you’ve created a Tableau Prep flow, your next instinct should be to automate it! If you happen to be fortunate enough to be working on Tableau Server, you know that you can upload Prep flows to your server instance, and schedule automated tasks with ease.

But what if you’re a startup or solo practitioner without the budget to afford the Tableau Server license and hardware? It’s just not practical or reliable to run your Prep flows manually every morning from your workstation.

Fortunately, certain Tableau Prep functions can be activated from the command line. With the help of a few configuration files, you can use the Windows Task Scheduler to run your flows at regular intervals.

Let’s get started!

What You’ll Need

  1. A Tableau Prep flow file (.tfl)
  2. A JSON file with credentials to your data sources and outputs.
  3. A Shell Script authenticating Tableau Prep to use your credentials.
  4. A Windows Task Scheduler Event

1. A Tableau Prep Flow file (.tfl)

Get the system path to your flow file and copy it down.

Example:
C:\Users\MyName\Documents\my_prep_flow.tfl

Note: If the File or Directory names contain spaces, this will cause errors. You will need to remove spaces or replace with underscores.

2. A JSON File with your Credentials

Copy and paste the template below into a text file, switch your credentials for the data source(s) and output destination(s) as applicable, then save it as connections.json in a safe location (I suggest creating a Scripts folder in your system’s Documents).

{"inputConnections": [{"username":"DATABASE USER",
"password":"DATABASE PASSWORD",
"hostname":"DATABASE HOST",
"port": PORT,
}],"outputConnections": [{"username":"DATABASE USER",
"password":"DATABASE PASSWORD",
"serverUrl":"DATABASE HOST",
"contentUrl":"",
}]}

Example:

Saved to: C:\Users\MyName\Documents\Scripts\connections.json

Notes: a) In the Save As dialog, select All Files (*.*) under Save as type before saving. This will ensure that your connections.json file is saved with a JSON file extension. b) If the Directory your credentials file is stored in contains spaces, this will cause errors. You will need to remove spaces or replace with underscores.

3. A Shell Script to Run Tableau Prep with your Credentials

Copy and paste the template below into a text file, switch the file locations, and save it somewhere safe (such as a Scripts folder in your system’s Documents) as the name of your prep flow with the extension .bat

cd C:\Program Files\Tableau\Tableau Prep 2019.4\scriptstableau-prep-cli.bat -c C:\my-path-to\connections.json -t C:\my-path-to\my_prep_flow.tfl

Example:

cd C:\Program Files\Tableau\Tableau Prep 2019.4\scriptstableau-prep-cli.bat -c C:\Users\MyName\Documents\connections.json -t C:\Users\MyName\Documents\my_prep_flow.tflSaved to: C:\Users\MyName\Documents\Scripts\my_prep_flow.bat

Important Note: Tableau Prep versions have been updating fairly rapidly — as new versions are released, the version name of the app changes as well. Update this script accordingly to ensure your flows keep running on the latest version you have installed.

4. A Windows Task Scheduler Event

On your Windows system, open:
Task Scheduler > Select Action > Create Basic Task

  • Choose a name and a description for your task and click Next.
  • In the Trigger menu, select an option for the frequency you want your task to run, the start date, and the start time, and then click Next.
  • In the Action menu, select Start a program, click Next, click Browse, and select the .bat file you created in step 3. Click Next and then click Finish.

Your Prep flow should now run on the dates and times you selected!

Wrapping Up

Advanced users might consider using cron from the command line instead of Task Scheduler, but either approach will work.

Special thanks to AJ Jones at Tinuiti for troubleshooting our Windows procedures.

There you have it — now get out there and automate all the things!

--

--

Jeff Parks

I drink Cafecito and know things. Director of Analytics, providing measurement strategy & data insight for national brands.