Table Extensions

Table Extensions allow you to create data tables with an analytics extensions script. You can write a custom TabPy or Rserve script and optionally add one or more input tables. Table extensions are supported by Tableau Cloud, Tableau Server, and Tableau Desktop. This document focuses on Tableau Cloud.

Note: Similar to a live connection, the Table Extension refreshes every time you open up a workbook or refresh a data source.

Benefits

Table Extensions have the following benefits for both new and experienced users.

  • Easily integrate scripts or advanced functions into Tableau

  • Easily drag data from Tableau data connections as input into scripts

  • Low code editor makes adding code to data sources easy

  • Integrates with Data Guide and Explain Data
  • Integrates with TabPy, Rserve, and other analytics extensions

  • Results can be used to construct dashboards or visualizations

Prerequisites

Before you can use table extensions, you must complete the following list.

Create a Table Extension

To create a table extension, complete the following steps.

  1. Open a published workbook.
  2. Open a data source or create one.
  3. Under connections, choose New Table Extension.

    connections menu

  4. Drag it into the data model.
  5. (Optional) Drag tables from the data connection into the table extension pane to use as input into your analytics extensions script or function.

    • By default data from Tableau is passed to the analytics extension and defined as the variable _arg1, a dictionary-like structure such as: {‘colum_name’: [1,2,3], ‘column_name_2’: [3,4,5]

      Python example: The input data could be converted to a pandas dataframe using the following.

      import pandas as pddf = (pd.DataFrame(_arg1))

    • When using RServe, the input data is defined as the variable .arg1 and the data type are a named list of lists.

    • For supported relational data sources, you can use Custom SQL as an input into a table extension. When parameters are used in the Custom SQL query, changing the parameter causes the query to rerun and the script to recompute. This creates a path to dynamically update parameters in a dashboard and filter or otherwise pass values to the table extension script.

      relational data sources

  6. In the Script area, enter your script or function call. The script must return a dictionary or list of lists, essentially a JSON object. A script for RServe must return a data.frame or list of named lists while the script for Python must return a dictionary.

    Python example: We use the following explicit return command.

    return df.to_dict(orient='list')

  7. Note: Table extensions don't support directly calling TabPy endpoints if TABPY_EVALUATE_ENABLE is disabled in TabPy.

  8. Select Apply to run the script.
  9. (Optional) If you’re relating the table extension to another table in the data model, define the relationship between at least one field in each table. If the fields have the same name, this may happen automatically.

  10. Choose Update Now and the results appear in the Output Table tab.

    output results table

Note: If you don't define a relationship to a table in the data model, the Input Table tab is empty and will display the message ‘Data preview unavailable’.

  1. (Optional) In the Name field, enter a unique name for your table extension.
  2. Go to the Sheet tab to start exploring and visualizing the data. Results from a table extension functions like any other data in Tableau queried from a flat file or relational source.
  3. Publish the workbook to share it. The publishing destination, Server or Tableau Cloud, must have an analytics extension of the appropriate type enabled and configured.

Troubleshooting tip: Errors from analytics extensions will be surfaced in a Tableau error message if there’s a problem executing the script. If your table extension is hitting an error, ensure all code and formatting is correct and try using the circular Refresh Data Source button, located next to the Save button, or click Apply again.

Table Extensions vs Analytics Extensions

While some of these products aren't related, table extensions and analytics extensions share several features. The table extensions feature relies on a connection with analytics extensions to work. Let's break down each feature.

Dashboard Extensions

Dashboard extensions allow custom web applications to be added to dashboards using the Dashboard Extension SDK, however, this extension type isn’t related to table extensions.

Table Extensions

The Table extensions feature lets you create a table in a data source that can send data and a script to your analytics extension and return a full table of arbitrary shape as a result. The returned results are displayed as a table in the data model in the Data Source tab and as measures and dimensions in the workbook.

Analytics Extensions

The Analytics extensions feature allows you to extend Tableau calculations with programming languages like Python, external tools, and external platforms. After you create a connection to an analytics extension, you can communicate with your external server through calculated fields called SCRIPT_X or MODEL_EXTERNAL_X, where X is the data type of the expected return values. For more information, see Pass Expressions with Analytics Extensions.

Thanks for your feedback!Your feedback has been successfully submitted. Thank you!