1 Reply Latest reply on Feb 25, 2019 11:09 AM by Esther Aller

    Aliases for data sources in calculated fields?

    Richard Foxworthy

      I have a Tableau analysis sheet where I need to ingest new data files regularly with updated data. The data is in exactly the same structure each time, and each data source is labelled with year/month/day - Eg the data sources are named something like Data 2019-02-13 and Data 2019-02-14. I need to perform calculations and display changes in various values between these dates, and currently I'm do this by using blended data sources in my calculated fields like this:

       

      ATTR ([Total Cost]) - ATTR ([Data 2019-02-13].[Total Cost])

       

      Right now I need to update each calculated field to find variation from previous data file. Is it possible to label these data sources something like 'Current' and 'Previous' so that my calculated fields can refer to the labels rather than to the actual date-named data sources - something like:

       

      ATTR ([Current].[Total Cost]) - ATTR ([Previous].[Total Cost])

       

      ie so that each time I add a new data source all I would need to do is label most recent one 'Current' and relabel previous one to 'Previous', and all my calculated fields would update.

       

      I don't want to actually rename the data source since its important for me to know what date each file was generated.

       

      Thanks

        • 1. Re: Aliases for data sources in calculated fields?
          Esther Aller

          Hi Richard,

           

          So this is currently not possible for two reasons, Tableau does not have the ability to give data sources aliases, and calculations cannot use alias values.

           

          Are your data files text files? If so, I recommend creating a wildcard union. A wildcard union means that new text files added to the same folder will be automatically added in Tableau the next time the connection is refreshed (there is some flexibility around the logic you can use for which files are included).

           

          AND if all of your data is unioned then there will be only 1 [Total Cost] field. Depending on exactly how your view is set up the exact calculation will differ, but you can probably use something like:

           

          SUM([Total Cost]) - LOOKUP( SUM( [Total Cost] ), -1 )

           

          The above calculation will subtract the SUM([Total Cost]) from the previous row/column from the SUM([Total Cost]) in the current row/column.

           

          Hope this helps