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.

Note: A table extension refreshes every time you open up a workbook or refresh a data source.

Benefits

Table rxtensions 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
  • A 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 workbook.
  2. Open a data source or create a one.
  3. Under Connections, choose New Table Extension.
  4. Drag the sheet 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: {‘column_name’: [1,2,3], ‘column_name_2’: [3,4,5]

    • Python input data: The input data could be converted to a pandas dataframe using the following: import pandas as pddf = (pd.DataFrame(_arg1))
    • RServe input data: The input data is defined as the variable.arg1 and the data type are a named list of lists.
    • Custom SQL input data: 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.

      Note: If a parameter is used in a table extension, that parameter can't be deleted until it's removed from the extension. Deleting a parameter called in table extension can trigger a fatal error.

      relational data sources

  1. Under Script, enter your script or function call. The script must return a dictionary or list of lists, such as a JSON object. A script for RServe must return a data.frame or list of named lists. A script for Python must return a dictionary.
    • Python example: Use the following explicit return command: return df.to_dict(orient='list')
    • Note: Table extensions don't support directly calling TabPy endpoints if TABPY_EVALUATE_ENABLE is disabled in TabPy.

  2. Select Apply to run the script.

    script dialog

  3. (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.
  4. In the data grid under Output Table, choose Update Now.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 displays the message ‘Data preview unavailable’.

  1. (Optional) In the Name field, enter a unique name for your new table extension.
  2. Go to the Sheet tab to start exploring and visualizing the data.
  3. Publish the workbook to share it. The publishing destination must have an analytics extension of the appropriate type enabled and configured.

Troubleshooting tip: If your table extension is hitting an error, first ensure all code and formatting is correct. Then try using the circular Refresh Data Source button in the toolbar or click Apply again.

Compare extension types

While some of the following 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.

Table Extensions

Table extensions let you create a table in a data source that can send data and a script to your analytics extension and return a full table as a result. The returned results are displayed as a table in the data model and as measures and dimensions in a 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!