3 Replies Latest reply on Dec 4, 2019 12:20 AM by Adrian Vogelsgesang

    Can I use Tableau Hyper API to create a dimension hierarchy in .hyper extracxt?

    Deric Cunningham

      In Tableau Desktop, a dimension hierarchy can be included in a .hyper extract by building the hierarchy on the Sheet tab before extracting the data source into a .hyper file - https://help.tableau.com/current/pro/desktop/en-us/qs_hierarchies.htm

       

      Is similar functionality available using the Hyper API?  I looked through the Hyper API docs here and didn't see a way to do this.

        • 1. Re: Can I use Tableau Hyper API to create a dimension hierarchy in .hyper extracxt?
          Jacob Sovoda

          Anyone have any ideas here? I am also lost on if this is possible or not using the Hyper API.

          • 2. Re: Can I use Tableau Hyper API to create a dimension hierarchy in .hyper extracxt?
            Adrian Vogelsgesang

            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.

             

            Cheers,
            Adrian (developer, Hyper team)

            • 3. Re: Can I use Tableau Hyper API to create a dimension hierarchy in .hyper extracxt?
              Adrian Vogelsgesang

              Deric Cunningham did the proposed solution of using a hard-coded twb work for you?