---
schema_version: "1"
id: 7466612531e90b6b9727bbebcf38dc468092ac07ee574358c94d58268f5c5b5e
title: Get Predictions in Tableau Calculated Fields
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/analytics/264-0-0/bi_edd_tableau_script.md
canonical_url: https://help.salesforce.com/s/articleView?id=analytics.bi_edd_tableau_script.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 58d61853e55ac38c348e188843b1877c23281f52d313d0546b62c36f103e5dad
description: It’s easy to get Einstein Discovery predictions in calculated fields. In Model Manager, simply select a prediction definition, generate a Tableau script, and then copy and paste the script into a Tableau calculated field.
products:
  - CRM Analytics
  - Cross Cloud
release: "264"
---
# Get Predictions in Tableau Calculated Fields

It’s easy to get Einstein Discovery predictions in calculated fields. In Model Manager, simply select a prediction definition, generate a Tableau script, and then copy and paste the script into a Tableau calculated field.

To embed Einstein Discovery predictions in Tableau calculated fields:

1. Log into Salesforce with a user account that has the **Manage Einstein Discovery** permission assigned to it.
2. Open CRM Analytics Studio.
3. Open Model Manager.
4. [View a Prediction Definition](https://help.salesforce.com/s/articleView?id=analytics.bi_edd_model_manager_view.htm&release=264.0.0&type=5 "Manage a prediction definition and its associated models.").
5. Click the **Advanced** tab.
6. Choose **Create Tableau Table Calculation**.
    
    ![Settings tab, showing the button Create Tableau Table Calculation](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/bi/images/bi/bi_edd_tableau_script_create.png)
    
    Model Manager generates a script containing the ID of the prediction definition you want to use, the columns (variables) used in the model, and the corresponding source columns in Tableau (which you can edit later in Tableau).
    
    ![Location of Copy to Clipboard link](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/bi/images/bi/bi_edd_tableau_script_copy.png)
7. Click **Copy to Clipboard**.
8. In your Tableau worksheet, paste the script generated from Model Manager into the Calculation Editor for the target calculated field.
    
    ![Calculation editor with Table Calculation selected](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/bi/images/bi/bi_edd_tableau_script_paste.png)
9. Optionally, modify the script to include additional parameters.
    
        
    | Optional Parameter | Description | Regression | Binary Classification | Multiclass Classification |
    | --- | --- | --- | --- | --- |
    | maxMiddleValues | The number of top predictors to return in the response. | ![Checkmark icon indicating true](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/resources-global/_corporate/images/checkmark.png) | ![Checkmark icon indicating true](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/resources-global/_corporate/images/checkmark.png) |   |
    | maxPrescriptions | The maximum number of improvements to return in the response. | ![Checkmark icon indicating true](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/resources-global/_corporate/images/checkmark.png) | ![Checkmark icon indicating true](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/resources-global/_corporate/images/checkmark.png) |   |
    | showMultiClassProbabilities | Determines if probabilities are displayed. |   |   | ![Checkmark icon indicating true](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/resources-global/_corporate/images/checkmark.png) |
    
    Here is an example script that includes optional parameters to create a Table Extension in Tableau:
    
    ```
    {
    “modelOrPredictionDefinitionId”: “1ORB0000000HC3KOAW”,
    “columns”: [“Postal_Code”, “City”, “Ship_Mode”, “Row_ID”, “Profit”, “Category”, “Sub_Category”, “Order_Date”, “Quantity”, “Ship_Date”, “Region”, “Sales”, “State”, “Segment”], 
    “maxMiddleValues”: 3,
    “maxPrescriptions”: 5,
    “showMultiClassProbabilities”: false
    }
    ```
    
    Here is an example script that includes optional parameters to create a Table Calculation in Tableau:
    
    ```
    SCRIPT_REAL(
    '{ "modelOrPredictionDefinitionId": "1ORB0000000HC3KOAW",
    "columns": ["Postal_Code", "City", "Ship_Mode", "Row_ID", "Profit", "Category", "Sub_Category", "Order_Date", 
         "Quantity", "Ship_Date", "Region", "Sales", "State", "Segment"],
    "maxMiddleValues": 3,
    "maxPrescriptions": 5,
    "showMultiClassProbabilities": false }',
    SUM([Postal Code]), ATTR([City]), ATTR([Ship Mode]), SUM([Row ID]), SUM([Profit]), ATTR([Category]), ATTR([Sub-Category]), 
         ATTR([Order Date]), SUM([Quantity]), ATTR([Ship Date]), ATTR([Region]), SUM([Sales]), ATTR([State]), ATTR([Segment])
    )
    ```
10. If needed, replace the column names inside each ATTR or SUM function with the name of the matching column in your Tableau data, then click **OK**.
    
    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.

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/images/icon_note.png)

Note For detailed Tableau instructions, refer to [Einstein Discovery](https://help.tableau.com/current/pro/desktop/en-us/r_connection_manage.htm#Einstein2) in [Pass Expressions with Analytics Extensions](https://help.tableau.com/current/pro/desktop/en-us/r_connection_manage.htm) in Tableau Desktop help.

#### See Also

- [Manage Prediction Definitions and Models](https://help.salesforce.com/s/articleView?id=analytics.bi_edd_model_manager.htm&release=264.0.0&type=5 "Use the Model Manager to view, configure, and manage prediction definitions and models that have been deployed in your org.")
- [Get Predictions in Tableau](https://help.salesforce.com/s/articleView?id=analytics.bi_edd_tableau.htm&release=264.0.0&type=5 "Einstein Discovery in Tableau provides predictions and improvements for Tableau data in worksheets, calculated fields, and flows.")