Tableau Web Data Connector Node Generator

Using Tableau Web Data Connector (WDC) as the data source for dashboard.
This post is in reference to the associated Github repo at https://github.com/mortie23/tableau-wdc-gen.
Reason:
- The data we are sourcing is in SAS.
- If using Tableau Public the only server sources are Google Sheets and Tableau WDC.
- Tableau WDC is the easiest way to have a Tableau Public dashboard sourcing from a server that can be updated independently of the dashboard.
Background
If you are interested in the details of how this package works it is built from knowledge gained through this tutorial.
https://tableau.github.io/webdataconnector/docs/wdc_tutorial.html
Generate the data
To generate the JSON that this package uses we will use the SASjs macro core library. Directly using proc json
adds a high level array element to the JSON output that we don’t want: ['SASTableData+<filename>']
.
This means that we create a clean JSON output and we would be able to use different tools in the future and not have legacy SAS generated objects.
Documentation on the SASjs mp_jsonout
macro can be found at: https://core.sasjs.io/mp__jsonout_8sas.html
The key steps are to create two file handles (one for the data, and one for the metadata) and use the SASjs macro to write the files out.
* Create filename handle for files to write to;
filename json "&outdir./datasourcename.json";
filename jsonmeta "&outdir./datasourcename_meta.json";
* Export to JSON;
%mp_jsonout(OBJ,datasourcename,jref=json)
%mp_jsonout(OBJ,datasourcename_meta,jref=jsonmeta)
Create the WDC
A WDC needs the following 4 files:
Description | |
---|---|
filename.html | WDC page |
filename.js | WDC script |
filename.json | The dataset as JSON array |
We will used a node
script to generate these files from the metadata.
Run the node script
This has been tested on Node.js 12.19.0 on for Windows 10
run using Powershell.
node .\script\tableauwdc.js --filename <filename (no extension)> --title "<a title for the dataset with quotes>" [--geojson]
## example of flat tabular data from SAS
node .\script\tableauwdc.js --filename classdata --title "Class Data"
## example GeoJSON data
node .\script\tableauwdc.js --filename geo_earthquake_4.5_week --title "Geo Earthquake 4.5 week" --geojson
You should see a quick summary of some validations and a prompt to continue.
Do not continue if your validation fails.
When you pass the validations, then continue, your WDC should be built.