Introduced in 2020.2, relationships are a new way of connecting different data objects. While joins happen on the physical layer of the data source, relationships happen at the logical layer. This means that there is no new data source created, and Tableau will automatically handle duplicates and null values.
Relationships are the default way used by Tableau to connect data objects. Therefore, the process of using relationships requires fewer steps than joins. To start using relationships with your tables, follow these steps:
- Drag a table from the left side of the screen.
- Drag the second table you wish to join from the left side of the screen.
- If Tableau has enough information, it will set up an automatic relationship.
- If Tableau cannot establish a relationship automatically, it will highlight the problem just as it finds a link. It will highlight the problem with a triangle, as shown in Figure 3.20:
Figure 3.20: Tableau indicating it cannot automatically create a relationship between two tables
- If that is the case, you can use the menu at the bottom of your screen to specify which fields should be used to establish the relationship.
- Just as before, the join is configured so that Tableau can use the table Account with the table Contact by using the field Account ID present in both tables but labeled as Account ID (Contact) in the Contact table, as shown in Figure 3.21.
Figure 3.21: Manually defining the relationship in Tableau using the relationship editor
- As you can see, the red triangle mark has disappeared, and the two tables are now joined. This process can be repeated on as many objects as necessary. Simply drag any additional table into the join area, as shown in Figure 3.22, and proceed with the steps defined above.
Figure 3.22: Multiple tables successfully related in Tableau
To remove a table, follow the same steps outlined in the Joins section.
At first glance, it may seem that relationships and joins are quite similar, if not identical. However, there are differences in their substance and behaviors worth understanding to decide which option to use.
The obvious advantage of relationships is that they do not require any prior understanding of SQL-like join behavior, which makes them a great option for beginner users. Advanced users, however, may prefer the additional degree of flexibility that comes from defining which type of join to employ and which fields to use.
It is also worth mentioning that relationships may not work as intended for data where the quality is exceptionally poor and may cause performance issues if large quantities of data are needed.