2 Replies Latest reply on May 12, 2010 2:41 PM by James Baker

    Table Calculation as Calculated Field

    . BCampolo

      Hi All-


      I have created a workbook that uses a Table Calculation, but I would like to use the results of this Table Calculation in another field.  I understand that Table Calculations cannot be used in other calculations, so I'd like to know the detail behind the Table Calculation.  Does anyone know how to re-create a Table Calculation as a Calculated Field?


      The Table Calculation I am using is:


      Calculation Type: Difference From


      Caulcate the difference within [Qtr}

      Display the current value as a difference from: Previous



      Thanks all!

        • 1. Re: Table Calculation as Calculated Field
          Joe Mako

          If you want to make use of Table Calculations in your Calculated fields in Tableau, the best route I know of is to preprocess your data. How to preprocess your data depends on your data source.


          If your data source is a database like SQL Server, PostgreSQL, or others, what you are looking for is commonly called Windowing functions, in your case, a Lag function. You can either write a Custom SQL statement when connecting, or add a table to your database prepared for Tableau with those calculations already done. You will want to check your database documentation to see if those types of functions are available.


          If your source data is in Excel, you can simply add another column where your calculation is performed.


          Another option you have if you are not connected to a live data source is to create a worksheet in Tableau that uses the Tableau Calculation results that you want to use along with any other fields, and export the data. When you connect to this exported data, you can then use the results of the Table Calculation in a calculated field. and produce your final results.

          • 2. Re: Table Calculation as Calculated Field
            James Baker

            Tableau does not currently have this capability.  Calculated Fields are things that the database can do - they are translated in to SQL and sent directly to the database.  Table Calculations do things that the database can't do - they operate on result sets that have already been fetched from the database.