在输入步骤中添加更多数据

  • 版本 :2022.1 及更高版本

注意:从版本 2020.4.1 开始,您现在可以在 Tableau Server 和 Tableau Online 中创建和编辑流。除非特别说明,否则本主题中的内容适用于所有平台。有关在 Web 上创作流程的详细信息,请参阅Tableau Server(链接在新窗口中打开)和Tableau Online(链接在新窗口中打开)帮助。

连接到数据源并开始构建流后,可能需要在新数据传入时刷新数据连接。您还可以在输入步骤中联接或合并数据集,以提高处理较大数据源的效率。

在“输入”步骤中刷新数据

如果在开始使用流程后输入文件或表中的数据发生更改,则可以刷新“输入”步骤以引入新数据。

文件输入步骤类型

注意:Web 尚不支持此选项。

要刷新文件输入步骤,请执行下列操作之一:

  • 在顶部菜单的流程窗格中,单击“刷新”按钮以刷新所有输入步骤。要刷新单个输入步骤,请单击刷新按钮旁边的下拉箭头,然后从列表中选择输入步骤。

  • 在流程窗格中,右键单击要刷新的输入步骤,然后从菜单中选择刷新


文件、数据库或 Tableau 数据提取输入步骤类型

若要刷新数据库或 tableau 数据提取输入步骤,请执行下列操作之一:

  • 尝试编辑连接。

    注意:为了保持性能,Tableau Prep 会对大型数据集进行采样。如果对数据进行了采样,则可能会在配置文件窗格中看到新数据,也可能不会看到新数据。您可以在“输入”步骤的“数据示例”选项卡中更改数据采样方式的设置,但这可能会影响性能。有关设置数据样本数量的详细信息,请参阅设置数据样本大小(链接在新窗口中打开).

    1. 在“连接”窗格中,右键单击或按住 Ctrl 键并单击 (MacOS) 数据源,然后选择“编辑”。

    2. 通过登录到数据库或重新选择文件或 Tableau 数据提取来重新建立连接。

  • 删除输入步骤并将其重新添加到流中。

    1. 在流程窗格中,右键单击要刷新的输入步骤,然后从菜单中选择删除

      This will temporarily put your flow in an error state.

    2. Connect to the updated file again.

    3. Drag the table to the flow pane on top of the second step in the flow where you want to add the Input step. Drop it on the Add option to reconnect it to the flow.

Union files and database tables in the Input step

Note: Input unions can't be edited or created in Tableau Server or Tableau Online. Only in Tableau Prep Builder.

When working with multiple files or database tables from a single data source, you can search for files or tables using a wildcard search and then union the data to include all of the file or table data in the Input step. To union files, the files must be in the same parent or child directory.

New files that are added to the same folder that match the pattern are automatically included in the union the next time you open the flow or run it from the command line. Packaged flow files (.tflx) won't automatically pick up new files because the files are already packaged with the flow. To include new files for packaged flows, open the flow file (.tfl) to pick up the new files, then repackage the flow to include the new file data.

To union database tables, the tables must be in the same database and the database connection must support using a wildcard search to union. The following databases support this type of union:

  • Amazon Redshift

  • Microsoft SQL Server

  • MySQL

  • Oracle

  • PostgreSQL

If you add or remove files or tables after you create the union you can refresh the Input step to update your flow with the new or changed data.

Note: Currently, this feature applies only to Excel and .csv (text) files and data tables stored in the specific databases listed above. This option is not available for Tableau data extracts.

Wildcard union for files is available in Tableau Prep Builder version 2018.1.2 and later. Wildcard union for database tables is available in Tableau Prep Builder version 2018.3.1 and later. Editing a flow connection with this type of union in a prior version can result in errors.

If you need to union data from different data sources, you can do that using a Union step. For more information about creating Union steps, see Union your data(Link opens in a new window).

Union files

By default, Tableau Prep Builder unions all .csv files in the same directory as the .csv file you connected to or all the sheets in the Excel file you connected to.

If you want to change the default union, use the following criteria to find the files or sheets you want to include in the union:

  • Search in: Select the directory to use to search for files. Select the Include subfolders check box to include files in the sub-directory of the parent folder.

  • Files: Select whether to include or exclude the files that match the wildcard search criteria.

  • Matching Pattern (xxx*): Enter a wildcard search pattern to find files that have those characters in the file name. For example, if you enter ord* all files that include the file name are returned. Leave this field blank to include all of the files in the specified directory.

To union files in the input step, do the following:

  1. Click the Add connection button and under Connect, click Text File for .csv files or Microsoft Excel for Excel files, and then select a file to open.

  2. In the Input pane, select the Multiple Files tab, and then select Wildcard union.

    The example below shows a wildcard union using a matching pattern. The plus sign on the file icon on the Orders_Central Input step in the Flow pane indicates that this step includes a wildcard union. The files in the union are listed under Included files.

  3. Use the search, file and matching pattern options to find the files that you want to union.

  4. Click Apply to union the files.

When you add a new step to the flow, you can see all the files added to the data set in the File Paths field in the Profile pane. This field is added automatically.

Union database tables (version 2018.3.1 and later)

  1. Click the Add connection button and under Connect,connect to a database that supports wildcard union.

  2. Drag a table to the flow pane.

  3. In the Input pane, select the Multiple Tables tab, and then select Wildcard union.

  4. Use search, Tables and Matching Pattern options to find the tables that you want to union.

    Only tables that display in the Connections pane in the Tables section can be included in the union. Wildcard search doesn't search across schemas or across the database connection to find tables.

  5. Click Apply to union the table data.

    When you add a new step to the flow, you can see all the tables added to the data set in the Table Names field in the Profile pane. This field is added automatically.

Merge fields after a union

After you create a union in the input step, you might want to merge fields. You can do this in any subsequent step, except for the Input or Output steps. For more information, see Additional merge field options(Link opens in a new window).

Join data in the Input step

In Tableau Prep Builder (version 2019.3.1 and later), and on the web, when you connect to databases that include tables with relationship data, Tableau Prep can detect and show which fields in a table are identified as the unique identifier and which fields are identified as a related field as well as show the related table names for these fields.

A new column called Linked Keys shows in the Input pane and shows the following relationships if they exist:

  • Unique identifier. This field uniquely identifies each row in the table. There can be multiple unique identifiers in a table. The values in the fields must be unique and cannot be blank or null.

  • Related field. This field relates the table to another table in the database. There can be multiple related fields in a table.

  • Both Unique Identifier and related field. The field is a unique identifier in this table and also relates the table to another table in the database.

You can leverage these relationships to quickly find and add the related tables to your flow or create joins from the Input step. This feature is available for any supported database connector where table relationships are defined.

  1. 连接到包含字段的关系数据(如唯一标识符或相关字段(外键))的数据库(如 Microsoft SQL Server)。

  2. 在“输入”窗格中,单击标记为相关字段或同时标记为唯一标识符和相关字段的字段。

    将打开一个对话框,其中显示相关表的列表。

  3. 将鼠标悬停在要添加或联接的表上,然后单击加号按钮将表添加到流程中,或单击联接按钮以创建与所选表的联接。

    如果创建联接,Tableau Prep 将使用定义的字段关系联接表,并显示将用于创建联接的联接子句的预览。

  4. 或者,您可以从“流程”窗格的菜单中联接相关表。单击加号图标,然后选择添加联接以查看相关表的列表。Tableau Prep 会根据构成两个表之间关系的字段创建联接。

    注意:如果您的表未定义表关系,则此选项不可用。