Anyone have any ideas here? I am also lost on if this is possible or not using the Hyper API.
Hi Deric and Jacob,
unfortunately, creating hierarchies is not supported through the HyperAPI.
If you create a hierarchy in Tableau, that hierarchy information is not actually stored in Hyper but rather as part of the datasource meta information in the twb/tds/tdsx/twbx file.
This means, that if you would only send the .hyper file to a colleague but would not share the corresponding tds/twb file, the hierarchy information would be lost.
The HyperAPI focuses on manipulating .hyper files. To create/manipulate hierarchies you would have to edit the tds/tdsx/twb/twbx file instead. Unfortunately, we don't offer any official API to do so. Instead you will have to use google and trial and error to figure out how to do this.
In general, this is doable because:
* twbx/tdsx files are just zip files under the hood and you can easily unzip/modify them using your favorite the zip tools/libraries. After unzipping, you will see that the twbx/tdsx file also contains the twb/tds file which holds all the informations re. hierarchies
* twb/tds files are XML files. You can use your favorite text editor to inspect them. You can play around with Tableau a bit and look at the XML created for various hierarchies until you understand how they are represented in the twb/tds. From there on, you can use your favorite XML library to create just the right XML for your use case.
In case you only need one hard-coded hierarchy, I would recommend to:
* use a hardcoded twb containing your hierarchy. Use Tableau once to generate this XML with the exact hierarchies you want.
* from your script, always package this constant tds/twb file together with the Hyper file created by your script into a tdsx/twbx file
* use the tdsx/twbx file with Tableau as usual. You should now also have your hierarchies in there.
Adrian (developer, Hyper team)