Difference between Tableau relationships and Joins

Difference between relationships and joins

In my previous blog How to create relationships in Tableau, we learned about relationships. In this blog, we will study the difference between Tableau Relationships and joins. We will also see if joins are still available in Tableau.

To explain this concept, I will use the following three tables,

Sample tables used to explain Relationships and Joins, tableau relationships vs joins
tableau relationships vs joins

*In Tableau, Joins work similar to database joins.

Difference between Tableau Relationships and Joins

  1. In Tableau, relationships are called the Logical layer and Joins are called the physical layer.
  2. As we understood in the previous blog, Relationships are not Joins. Relationships keep the tables separate and do not merge them into a single table.
  3. If you connect to MS-Excel source of these three tables, a relationship is created between Emp and Dept based on the common field DeptNo and a relationship is created between Emp and Salary based on JobID, which is shown below. (please comment below if you need these tables for your practice) 

Emp data is displayed

Three tables in a relationship, tableau relationships vs joins
Tables in relationship with data preview of Emp table

You will notice that the rows of Emp table only will be displayed in the preview window, since Emp table is selected. The rows from other two tables will NOT be displayed. This occurs because relationships keep the tables separate.

An analysis of data from these tables can be easily performed. For e.g. I can determine the Employees working in different departments and their respective salaries based on the job titles.

Tableau text table displaying data from all the three tables, tableau relationships vs joins
Tableau text table displaying data from all the three tables

In the earlier versions of Tableau, in the absence of a relationships, this task would have required data blending with multiple sources and would therefore be slow. Using relationships, we can do this in one datasource. Also, data blending is limited to a worksheet, but relationships are available for the entire workbook. Relationships will increase the performance of your dashboard.

Where are Tableau Joins?

Joins are still available and can be created as required.

  1. A Join between two tables merges the tables and creates a single table.  
  2. Joins between two tables are created based on the common field names. To create a join, you need to double click on the table in the logical/relationship layer and add another table next to it.
  3. To create a join between Emp and Dept tables, in the relationship, double click on the Emp table and add dept to it. You can choose the type of join you need.
Join between two tables, tableau relationships vs joins
Join between Emp and Dept tables

You can close this Join/physical layer by clicking on the cross on the right corner. This will navigate you back to the relationship layer. Notice the emp table will look different as it now contains a join.

Emp table in physical layer, tableau relationships vs joins
Emp table in logical layer displayed with a join

Compared to Relationships, Joins have some disadvantages

  1. Joins are static and once made, will affect the data in the entire workbook.
  2. Depending on the join type you use, you may lose unmatched data. For example, inner join shows only matching rows between the tables. Although emp table has 7 rows, you will see only 5 rows when inner join is used.
  3. If you use Left join, with Emp table on the left, you will get all the rows from the Emp table but dept table will show only the matching rows and therefore Deptno 800 will not be displayed.
    Data when left join is used, tableau relationships vs joins
    Data when left join is used

    4. If you use a Right join, with Dept table on the right, you will get all the rows from the dept table including DeptNo 800. The employees in Emp table that do not belong to any department, will not be displayed.

    Data using Right join, tableau relationships vs joins
    Data using Right join

5. This problem can be resolved by using outer join, but here again, if your tables are huge, this may result in slow performance. Due to this reason, Outer joins are not recommended.

All these problems will be resolved by using Relationships. You can still use joins but use them when absolutely necessary.

Tableau offers diverse techniques for merging data, such as, relationships, joins, unions, and data blending. Compare each method and learn which method to use in specific scenarios.

For more such tips and to become an expert in Tableau checkout my new Tableau book – Dashboarding with Tableau

To check your Tableau knowledge visit Tableau Quiz

Learn More


About the Author

Chandraish Sinha has  20+ years of experience in Information Technology. He is an accomplished author and has published 11 books covering Business Intelligence related topics such as, Tableau,Power BI, and Qlik. Checkout his Amazon Author profile.

His latest book Excel Basics to Advanced covers all the aspects of MS Excel and provides exercises for self-learning.

Similarly, his recent book, Dashboarding with Tableau, covers all the features in Tableau and includes exercises for self-learning.

He has implemented IT solutions in different domains viz. Pharmaceutical, Healthcare, Telecom, Financial and Retail.

He blogs regularly on various IT topics. Check them out in the links given below: 

Blogs

Learn Tableau

Learn All Bi

Related posts

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.