1 Reply Latest reply on Jul 5, 2013 6:55 AM by Russell Christopher

    How to rename my fields for friendly names using XML

    Tina Nalbandian


      I'm trying to change the field names in my workbook to give it a more friendly names.

      For example: OB_INVOICE_DT is the actual field name, and I'm changing it to OneBill - Invoice Date.

      I'm currently doing it through tableau desktop (selecting the filed and renaming it) however, this is pretty long since I have around 140 of them to change.


      I know that I can build a code that looks into the specific field in the tableau XML file and then makes the change (I already built a small code that works well for that) However,


      My problem is: My data is stored in a view in Teradata. with Tableau I'm connecting to the view. I then save it as a tds file (data-add to saved data sources). When I open the .tds file with notepad, I don't see the captions. I only see the number of records sample:

      <?xml version='1.0' encoding='utf-8' ?>

      <datasource formatted-name='teradata.41459.588461689818' inline='true' version='8.1' xmlns:user='http://www.tableausoftware.com/xml/user'>
        <!-- build 8000.13.0319.1225                -->
        <connection authentication='auth-teradata' class='teradata' disable-unicode='' enum-with-permissions='' expected-driver-version='' odbc-connect-string-extras='' odbc-native-protocol='yes' one-time-sql='' port='1025' query-band-spec='' server='SERVER NAME' username='USERNAME' >
          <relation name='INVC_SUM' table='V_INVC_SUM' type='table' />
          <connection-customization class='teradata' enabled='false' version='8.1'>
            <vendor name='teradata' />
            <driver name='teradata' />
              <customization name='CAP_CREATE_TEMP_TABLES' value='yes' />
              <customization name='CAP_SELECT_INTO' value='yes' />
        <column datatype='integer' name='[Number of Records]' role='measure' type='quantitative' user:auto-column='numrec'>
          <calculation class='tableau' formula='1' />
        <layout dim-ordering='alphabetic' dim-percentage='0.5' measure-ordering='alphabetic' measure-percentage='0.4' show-structure='true' />
          <semantic-value key='[Country].[Name]' value='&quot;United States&quot;' />


      Is this happening because I am connecting to a view and not an actual table? If so, is there a way to bypass it and have all the fileds that I see when I open my data in Tableau desktop in the XML file?


      Thank you

        • 1. Re: How to rename my fields for friendly names using XML
          Russell Christopher

          First, a small note of warning - what you're trying to do is not officially supported, even though it could be possible Therefore there are no "correct" answers to your question - instead, it's "whatever works"


          We don't always record each and every column into the XML of a data source when you connect. As you've seen, we populate:


          • Fields that you've renamed (we add a <column> element with a caption)
          • Calculated Fields (like "Number of Records") in your example
          • Fields which are geo-spatial in nature (City, State, Zip)


          ...and so on.


          If you join your table to another table, more stuff will get added: <map> values, additional <column> values for aggregated measures, and so on. We still won't always add a <column> for each and every field in the table though...we can figure some of this out at runtime and don't need to store it, I guess.


          SO, if your goal is to add a caption for each and every column you'll essentially need to add them yourself after you get a feel for how we generate them based on data type and how the column is used. Frankly, I think you'll find this'll take longer than just "captioning by hand" inside Desktop....


          Good luck!