Pass Expressions with Analytics Extensions

Tableau supports a set of functions that you can use to pass expressions to analytics extensions for integration with Einstein Discovery, R, MATLAB, and Python. Previously, this feature was referred to as "external services". In version 2020.1 (and later), this functionality is referred to as analytics extensions.

Once you have created a connection to an analytic extension, you'll communicate with your external service through calculated fields. Each calculated field uses the SCRIPT functions for expressions, operating as a table calculation.

Configure an analytics extension

Tableau allows connections to analytics extensions via a set of SCRIPT functions. Before you can pass any SCRIPT functions to your external service, you need to configure your connection to the service.

  1. In Tableau Desktop, click the Help menu, and then select Settings and Performance > Manage Analytics Extension Connection.

    Select the external service you want to connect to. MATLAB connections are managed by the Analytics Extension API.

  2. Select and configure your analytics service.

    • If you are using Einstein Discovery, select Enable. Your default browser will open, allowing you to authorize the connection to Salesforce. After connecting, go to the Einstein Discovery section of this help topic to continue.
    • For all other services (Tabpy, Matlab, and RServ), the following dialog will appear.
  3. Enter or select a server name using a domain or an IP address.

    If your server is using SSL encryption, select the Require SSL option. Tableau Server will read certificates installed in the operating system key store to establish the secured connection.

    Note: Tableau only supports PEM encoded certificates when connecting to TabPy or RServe.

  4. Specify a port.

    • Port 6311 is the default port for plaintext RServe servers.

    • Port 4912 is the default port for SSL-encrypted RServe servers.

    • Port 9004 is the default port for TabPy.

  5. Click Test Connection.

  6. Click Save.

If no connection can be established, an error message is displayed. Click Show Details in the message to see any diagnostic information returned by the server.

Einstein Discovery

Einstein Discovery is a powerful analytics tool in Salesforce that makes use of machine learning to provide insights and predictions. Einstein Discovery requires the Einstein Analytics Plus license, Tableau CRM Plus license, or the Einstein Predictions license, which are available for an extra cost. For related information, see Requirements for access.

For more information about Einstein Discovery, see Getting Started with Discovery(Link opens in a new window), and Explain, Predict, and Take Action with Einstein Discovery(Link opens in a new window) in Salesforce help. You can also expand your knowledge with the Gain Insight with Einstein Discovery(Link opens in a new window) trail in Trailhead(Link opens in a new window).

Note: Einstein Discovery in Tableau is powered by opens in a new window). Consult your agreement with opens in a new window) for applicable terms.

Integrate Einstein Discovery models into Tableau

With Tableau connected to the Einstein Discovery analytics extension, you can embed predictions directly in calculated fields. In Salesforce, use Model Manager to auto-generate a Tableau table calculation script, and then paste that script into a calculated field for use in a Tableau workbook. The table calculation script accesses predictive models deployed in Salesforce by calling the prediction ID and passing the data required for the model.

  1. Open your Einstein Discovery Salesforce account and navigate to the Model Manager. Select a model to integrate into Tableau. On the model tab, select Edit Settings > Create Tableau Table Calculation.

    Model Manager generates a script containing the ID of the prediction definition you want to use, the fields (variables) used in the model, and the corresponding source fields in Tableau.

  2. Click Copy to Clipboard.

  3. In a Tableau workbook, select Analysis > Create Calculated Field, and then paste the generated script in the Calculation Editor.

    If the field names are different from the Salesforce dataset the model was trained on, these fields are displayed with a red underline. You will need to edit these field names to match the correct field names in Tableau.

    Replace the fields names inside each ATTR or SUM function with the name of the matching field in your Tableau data, then save the calculated field.

    The calculation can be used just like any other Tableau calculation. For more information, see SCRIPT functions for expressions below.

    When the script runs, it sends a prediction request (with the input data) to the prediction definition in Salesforce. Einstein Discovery returns the results to Tableau, where it appears in your worksheet or dashboard.


R is an open source software programming language and a software environment for statistical computing and graphics.

Watch a Video: To see related concepts demonstrated in Tableau, watch the free training videos How to Integrate R and Tableau(Link opens in a new window) (4:40 minutes) and Using R with Tableau(Link opens in a new window) (4:44 minutes). Use your opens in a new window) account to sign in.

Implementing RServe connections

For R, you need access to a server which allows applications to access R functionality. See RServe(Link opens in a new window) for details. For information on installing, running, and configuring RServe, as well as on optimizing R scripts and R security, see the Tableau Community post R Implementation Notes(Link opens in a new window). For more information about using R with Tableau, see the blog post Tableau 8.1 and R(Link opens in a new window).

Tableau Desktop can connect to R via either plaintext or SSL-encrypted traffic. For direction on which type to use, consult your system administrator.

Note: For R integration, Tableau has been tested with R versions 3.4.4 through 3.5.1, and with RServe versions 0.6-8 through 1.7.3.

Intermediate certificate chain for RServe analytics extension

As of Tableau Server version 2020.1, you must install a full certificate chain on Tableau Desktop computers (Windows and Mac) that are connecting to a Rserve external connection through Tableau Server. This requirement is due to how Rserve manages the handshake on secure connections.

Importing a root certificate on the Tableau Desktop is not sufficient, the entire certificate chain must be imported onto the client computer.


MATLAB is a high-level language that connects through the Analytics Extension API that enables you to perform computationally intensive tasks faster than with traditional programming languages such as C, C++, and Fortran. You can use MATLAB in a wide range of applications, including signal and image processing, communications, control design, test and measurement, financial modeling and analysis, and computational biology. For information on how to configure your MATLAB server to work with Tableau please contact MATLAB support.

To read more about the possibilities of MATLAB in Tableau, see Put your MATLAB models and algorithms to work in Tableau(Link opens in a new window).


Python is a widely used high-level programming language for general-purpose programming. By sending Python commands to an analytics extension, you can do things like predicting customer churn or running sentiment analysis.

Tableau Python Server (TabPy) is part of Tableau's expanding range of extensibility options. To install TabPy, visit this GitHub page(Link opens in a new window). To read more about the possibilities of Python in Tableau, see Building advanced-analytics applications with TabPy(Link opens in a new window).

SCRIPT functions for expressions

In Tableau Desktop, a set of four SCRIPT functions are available for passing expressions to analytics extensions and obtaining a result. The functions are:





See SCRIPT_BOOL for details and examples. Because these SCRIPT functions are table calculations, addressing and partitioning concepts apply. (For an explanation of these concepts, see The basics: addressing and partitioning.) Tableau makes one call to an the analytics extension per partition.

Because connecting to an analytics extension involves some network overhead, it is often most efficient to pass data all at once rather than as individual row values whenever possible. For example if you set addressing to Cell (for example, by clicking the field in the view and choosing Compute Along > Cell), Tableau will make a separate call per row (created by each mark in the visualization) to the analytics extension. Depending on the size of the data, this can result in a very large number of individual calls.

The easiest way to ensure efficient calls are made to the analytics extension is to navigate to Edit Table Calculation and select Specific Dimensions then check the box next to each dimension to put that dimension on addressing. This will generate a single analytics extension call for the entire visualization. Any dimension left un-checked will be partitioned on, generating a separate call for each member in the visualization. If there are many marks in the visualization, it may be advantageous to select Pause Auto Updates while selecting dimensions to prevent frequent runs of the calculation before it is properly computed.

A calculation can be set to address specific dimensions by default by editing the calculated field and selecting the Default Table Calculation option in the bottom right-hand corner. In the Compute Using menu, select Advanced and then move the dimensions expected to the right hand space under Addressing. Note that this will cause the calculation to error if all addressed dimensions are not present in the visualization, though this can be corrected by editing the table calculation as described above and un-checking the dimensions not present.

Share a workbook that requires an analytics extension connection

You might need to send a workbook that contains analytics extension functionality to other users, who may be using different copies of Tableau Desktop on other computers. Or, users may download a workbook from Tableau Server that contains analytics extension functionality. If you share your workbook with someone, they must configure analytics extension connections on their computers.

Publish a workbook that requires an analytics extension connection

Before you publish a workbook that relies on an analytics extension connection to Tableau Server or Tableau Online, you must configure Tableau Server or Tableau Online to have its own analytics extension connection.

Thanks for your feedback!