Pass Expressions to External Services
Tableau supports a set of functions that you can use to pass expressions to external services for integration with R, MATLAB, and Python. Tableau supports integration with the following services:
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 (4:40 minutes) and Using R with Tableau (4:44 minutes). Use your tableau.com account to sign in.
MATLAB is a high-level language 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.
Python is a widely used high-level programming language for general-purpose programming. By sending Python commands to an external service, 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. To read more about the possibilities of Python in Tableau, see Building advanced-analytics applications with TabPy.
SCRIPT functions for expressions
In Tableau Desktop, a set of four SCRIPT functions are available for passing expressions to external services and obtaining a result. The functions are:
See SCRIPT_BOOL for details and examples. Because these SCRIPT_ functions are table calculations functions, addressing and partitioning concepts apply. (For an explanation of these concepts, see The basics: addressing and partitioning.) Tableau makes one call to an external service per partition.
Because connecting to an external service involves some overhead, try to pass values as vectors rather than as individual 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 to the external service; depending on the size of the data, this can result in a very large number of individual calls. If you instead use a column that identifies each row that you would use in the level of detail, you could compute along that column so that Tableau could pass those values in a single call.
Tableau allows connections to external services via a set of SCRIPT functions. In order to use these external services, you must establish a connection to an external server. Connections to Rserve, MATLAB Server, and Python Server are currently supported.
For R, you need access to a server which allows applications to access R functionality. See Rserve 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. For more information about using R with Tableau, see the blog post Tableau 8.1 and R.
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.
To configure an external service connection:
In Tableau Desktop, click the Help menu, and then select Settings and Performance > Manage External Service connection to open the External Service Connection dialog box:
Specify the type of external service you want to connect to: RServe or TabPy/External API. The TabPy/External API option covers connections to TabPy and MATLAB.
Enter or select a server by domain name or IP address. The drop-down list includes Localhost and the server you most recently connected to, as well as the Disable option.
Enter or select a server name using a domain or an IP address. The drop-down list includes localhost and the server you most recently connected to.
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.
If the server requires credentials, select Sign in with a username and password to enable the Username and Password fields. Add your credentials for these fields.
If your server is using SSL encryption, select the Require SSL option. Click the Custom configuration file... link to specify a certificate for the connection.
Note: Tableau only supports PEM encoded certificates when connecting to TabPy or RServe.
Click Test Connection.
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.
You might need to send a workbook that contains external service 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 external service functionality. If you share your workbook with someone, they must configure external service connections on their computers.
Before you publish a workbook that relies on an external service connection to Tableau Server, you should verify that the server is configured to be able to run scripts, and also configure Tableau Server to have its own external service connection. See "Configure Connection to External Services" (Windows | Linux) in the Tableau Server Help.
You cannot publish a workbook that contains external service scripting to Tableau Online.