4 Replies Latest reply on May 29, 2012 6:13 AM by Chris Ralph

    Replacing a data source by editing the workbook .xml

    Chris Ralph

      I'm having a lot of trouble replacing a data source in a large workbook I've created.  The two source datasets are identical in structure, and I've tried editing the connection as well as the "bookmark technique", but invariably I lose a bunch of calculated variables and/or end up with calculated variables that are corrupted and contain cryptic variable references I don't recognize at all. 

       

      My next thought is to try copying my original workbook, and then editing the .xml directly to replace the old data source with the new one.  Has anyone ever tried doing this? And if so, can you please describe what in the .xml you had to edit?

       

      As always any help would be very greatly appreciated!

      Chris

        • 1. Re: Replacing a data source by editing the workbook .xml
          Richard Leeke

          Briefly, it's easy if your data sources are the same type, trickier if they are different. I can't remember off the top of my head what the nuances are. What type of data source?

          • 2. Re: Replacing a data source by editing the workbook .xml
            Chris Ralph

            Both data sources are Tableau Data Extracts, which I converted from .csv files.  Any advice on which part of the .xml I need to edit would be great!

             

            Thanks!

            Chris

            • 3. Re: Replacing a data source by editing the workbook .xml
              Richard Leeke

              Thinking about this a bit more, I don't think your likely to have a lot of success in pointing a workbook at a different extract file - even if both extracts are generated from CSV files with the same structure. The problem is that the state of the workbook and the extract are very closely coupled and in ways that are not exposed to the user. So for example, if you create calculated fields, those are stored in the workbook with arbitrary internal names and often result in additional fields being stored in the extract. So even if you add the same calculations to two workbooks, the internal names used for those calculated fields will probably be different. That is the source of your cryptic references.

               

              So I think your best bet is to re-point your workbook at the new CSV file and allow Tableau to regenerate the extract. You can even explicitly remove the extract, point at a new CSV file and then generate a new extract.

               

              I often make a copy of the workbook with a new name, remove the extract from that, point at a new CSV and then generate a new extract with a different name. If you don't remove the extract first and just let Tableau regenerate you can end up overwriting your original extract.

               

              That should all work just using the user interface to edit the connection.

               

              Back to your original question, if you do end up directly editing the XML, you basically just need to search for all references to the filename and replace all of them with the new name. If your CSV file is called abc.csv, make sure you look for strings of abc#csv, too.

              • 4. Re: Replacing a data source by editing the workbook .xml
                Chris Ralph

                Hi Richard,

                Thanks very much for the detailed response!  I tried copying the workbook to go through the process you described, but when I remove the original extract all of my calculated variables and the worksheets that use them are deleted from my workbook, and they don't get re-generated when I connect to a new Excel file.. they're simply gone. 

                 

                I've also tried bringing in the Excel file (and the extract version of that Excel file) without deleting the original extract data source, and that generates the corrupted calculated variables.  This is the issue that led me to ask about editing the .xml instead.

                 

                I'm a bit disheartened here because this workbook took me several weeks to create, and it's now useless because I can't get it to work with new data.  If anyone has any other advice please let me know.

                 

                Thanks again!

                Chris