One of the things I often read about on the Alteryx forums is people asking how to publish to Tableau Server from Alteryx. Previously I wrote a post about publishing to Tableau Server from Alteryx using the Events functionality. A downside of this is the timing of the publish to Tableau – it either happens before or after the workflow has run.
There is an Alteryx tool that can publish a Hyper file to Tableau Server. However that has limitations. For example take the case where you have a local Hyper file, add some calculated fields and then publish the data source to the Tableau Server. This is common, it optimises the calculations within the Hyper file and also gives the calculations to anyone using Tableau data source. If you use the Alteryx built-in ‘Publish Hyper to Tableau Server’ tool this will overwrite the Tableau data source with a version that no longer contains the calculated fields. Clearly that would be far from ideal.
There is an alternative option without any of the aforementioned downsides. To publish to Tableau server from Alteryx use the Run Command tool and use tabcmd. This has two benefits:
- Publishing from the hyper from Alteryx to Tableau Server can happen from anywhere within the worklow
- The definition of the Tableau Data Source remains the same – i.e. calculated fields, default settings, etc are maintained
Using Tabcmd from Alteryx
The Alteryx Run Command tool allows the running of any command line script during a workflow. Tableau’s tabcmd enables publishing to Tableau Server direct from the command line. Therefore in Alteryx we can write a command line script calling tabcmd and execute that script using the Run Command tool, meaning we can publish directly to Tableau Server from Alteryx in a workflow.
Follow these steps for a simple example:
1. Add a Text Input tool and enter the filepath of the Tableau Data Extract (TDE) or Hyper file.
2. Add a Formula tool and create an Output Field called “cmd” with your script to run in the Command prompt. It’s recommended to create in Notepad initially and test it in the Command prompt to ensure it works as expected.
Write the tabcmd Publish command line script
3. The structure of the Command prompt script should be:
a. TabCmd location
b. Command to run on TabCmd – ‘publish’ in this example
c. TDE / Hyper file to publish to Tableau Server
d. Options/arguments required to publish using TabCmd. To maintain the existing Hyper data source definition include “–replace” to the end of the tabcmd command line. You don’t want to overwrite the Tableau data source, you want to replace it.
4. Use a Select tool and select the Output Field just created. Only the Command script should be loaded into the Run Command.
5. Add a Run Command tool:
a. In the Write Source Output section identify where the batch file should be saved. In the example I use the Alteryx temp directory (%temp%). Set it to be a csv File Format, no delimiter, no field names and no quoted output fields
b. Call the bat file just created in the Run External Program – Command area
The final workflow to publish to Tableau Server from Alteryx is as follows: