How to create relationships in Tableau

Relationships in Tableau are a new, easy and intuitive way to combine data from multiple tables from different data sources. Relationship is NOT a join or data blending. Let’s have a brief overview on how to create relationships in Tableau. 

Tableau introduced relationships between tables in version 2020.2. Prior to this version, it used joins to display data from two or more tables. 

If you are new to Tableau, learn how to connect to excel datasource in Tableau

How Tableau defines a Relationship?

Relationships are a new default to combine data from multiple tables from different sources.

  • When tables from different data sources are placed on data canvas, Tableau automatically creates a relationship between them.
  • A relationship is created based on the common field names between the tables.
  • The relationship works in the same way as database relationships.
  • Based on the data in tables, Tableau also assigns the cardinality (Performance Options) by default. If desired, you can change the columns on which the relationship is created and/or the cardinality.
  • Once the relationship is established, Tableau will automatically identify the join type when fields are used in the view.
  • Data blending is available as before.

A relationship in Tableau is shown below:

Tableau Between Emp And Dept Tables
Relationship created by Tableau between Emp and Dept tables

In the above figure, the relationship between Emp and Dept is created based on the common field Deptno.

Relationship between tables is NOT a join. A Join between two tables merges the tables and creates one table but a relationship keeps the tables separate.

When you click on the individual table in a relationship, data pertaining to only that table is displayed in the data preview.

How Tableau design interface changes when relationship is used

After creating the relationship, click on ‘sheet1 ‘at the bottom of the screen to go to the worksheet. You will observe a different new look of the data pane.

The new data pane will look like the one below:

Tableau between Emp and Dept tables

The following changes can be observed:

  • Dimensions and Measures of a given table are displayed within each table. They are divided by a gray line, refer to the dotted red line in the above picture.
  • Since the tables are not merged, there is no longer a ‘No of rows’ field . Instead, each table has its own row count – Dept (Count) and Emp (Count).
  • Calculations created using the fields from a specific table, will display within that table. Refer to Dept_Calc and Emp_Calc in the above picture.
  • Calculated fields created using fields from both the tables are displayed in a separate section at the bottom. I have created Emp-Dept_Calc using the fields from both dept and emp tables. It is displayed at the bottom of the field list. 
  • If you view the data, each table will be displayed in its own tab.
Emp-dept_calc
Each table has its own tab to display data

Creating relationships is an intuitive way to combine data from multiple tables. When using relationship option, you don’t have to know what joins to use but focus more on how tables are related.

Tableau provides various methods for combining data, including relationships, Joins, Unions, and Data Blending. Learn which method to use in specific scenarios.  

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.