4 Replies Latest reply on Jul 1, 2015 7:54 AM by Ricardo de la Cruz Martínez Ocádiz

    Changing field types using Extract API

    Ricardo de la Cruz Martínez Ocádiz

      Hi! I'm brand new to the Extract API, so far it's been great, now I want to know if there's a way to specify if a field will used as a dimension or a measure.

       

      Right now my problem is that I have a file with Purchase Orders and the field Unit price is showing in Tableau as a Measure and I would rather have it as a Dimension. I can change it in Tableau - I know - but I would love to be able to do it right from the API.

       

      Anyone knows if this is possible?

       

      Best Regards.

        • 1. Re: Changing field types using Extract API
          Russell Christopher

          Hey there!

           

          The short answer is no. An extract is just a collection of columns with data in them. It doesn't contain much in the way of "extra intelligence" that would allow you to pre-tag fields as measures / dimenions...just think of it as a fast database table.

          Just as Tableau "buckets" fields into measures and dimensions when you connect to a database table we've never seen before, we do the same thing for an extract.

           

          sorry, but iI nothing else you won't spent too much more time on this  

          • 2. Re: Changing field types using Extract API
            Jim Wahl

            One approach, especially if you're just regenerating or updating an existing TDE is to use a Tableau Data Source file along with the TDE.

             

            A TDS is an xml file that contains all of the meta data for the fields that you'd normally have in a workbook (TWB), including with it's a dimension or measure, the default formatting, ... . A TDSX also includes the TDE (or Excel, CSV, ..., files) packaged in a zip, similar to a twbx.

             

            And then you can distribute the tdsx file instead of just the tde (I'm assuming this is your end goal).

             

            Tableau doesn't publish the TDS schema, but if you're just updating / regenerating the TDE, you shouldn't need to do much if anything with the TDS file. On the other hand, the xml isn't complicated and I suppose you could generate the TDS yourself.

             

            You can generate a TDS file by right-clicking the data source inside a Tableau workbook > Add to saved data sources.

             

            Here's some more description:

            Exporting Data Sources

            1 of 1 people found this helpful
            • 3. Re: Changing field types using Extract API
              Ricardo de la Cruz Martínez Ocádiz

              Alas! I was afraid that was going to be the answer!

               

              Thanks!

              • 4. Re: Changing field types using Extract API
                Ricardo de la Cruz Martínez Ocádiz

                Jim,

                 

                This is a nice workaround. I also tried the following:

                 

                1. I created the TDE using the API.

                 

                2. Open it and made the changes to the Data in Tableau, i.e. I set the local price as a Dimension.

                 

                3. Saved the file and close it

                 

                4. Regenerate the TDE using the same name as the one related to the Tableau file.

                 

                5. Reopen the file and it respected the field types I set originally

                 

                Thanks for your answer!