Tableau 简明教程

Tableau - Data Joining

数据连接是任何数据分析中非常常见的需求。您可能需要连接来自多个来源的数据或连接单个来源中来自不同表的数据。Tableau 提供了使用数据菜单下编辑数据源中提供的“数据”窗格连接表的功能。

Data joining is a very common requirement in any data analysis. You may need to join data from multiple sources or join data from different tables in a single source. Tableau provides the feature to join the table by using the data pane available under Edit Data Source in the Data menu.

Creating a Join

考虑数据源“示例超级商店”,在“订单”和“退货”表之间创建连接。为此,请转到数据菜单并选择编辑数据源选项。接下来,将两个表(订单和退货)拖到“数据”窗格。Tableau 将根据字段名称和数据类型自动创建连接,此连接以后可以更改。

Consider the data source ‘Sample superstore’ to create a join between Orders and Returns table. For this, go to the Data menu and choose the option Edit Data Source. Next, drag the two tables, Orders and Returns to the data pane. Depending on the field name and datatype, Tableau will automatically create a join which can be changed later.

下图显示了使用字段订单 ID 创建订单和退货之间的内部连接。

The following screenshot shows the creation of an inner join between Orders and Returns using the Field Order ID.

data join 1

Editing a Join Type

表自动创建的连接类型可以手动更改。为此,请单击显示连接的两个圆圈的中间。下方出现一个弹出窗口,显示四种可用连接类型。此外,Tableau 根据数据源中存在的数据自动灰显某些类型的连接,认为这些连接无关。

The type of join which the table creates automatically can be changed manually. For this, click the middle of the two circles showing the join. A popup window appears below which shows the four types of joins available. Also Tableau automatically greys out some types of joins, which it finds irrelevant on the basis of data present in the data source.

在下图中,您可以看到内部连接和左外部连接作为可用连接。

In the following screenshot, you can see the inner and left outer join as the available joins.

data join 2

Editing Join Fields

您还可以通过单击连接弹出窗口中可用的数据源选项来更改形成连接条件的字段。在选择该字段时,您还可以使用搜索文本框搜索正在寻找的字段。

You can also change the fields forming the join condition by clicking the Data Source option available in the join popup window. While selecting the field, you can also search for the field you are looking for using a search text box.

data join 3