Joining Tables in Tableau: Welcome to Tableau Tutorial, in this tutorial you will learn how to combine multiple tables using joins in Tableau with an example.
Joining Tables in Tableau is a method for combining the related data on those common fields. Many Relational Data sources like Microsoft SQL Server, Oracle Database, MySQL and IBM DB2 are made up of tables that are related by specific fields like the first name, last name, phone number, etc. In order to analyze any two tables together, we must join the two tables using a common field that available in both tables.
Joining Tables in Tableau
For Joining Tables in Tableau, first, we need to connect to a data source using the connection dialog box. There you can add tables => specify joins => and modify the field aliases in the case you have similarly named fields in each of the tables. You can also add tables after you have already connected to the data source. This section describes how to connect to multiple tables as well as adding tables to the Data window. In general, there are four types of joins in Tableau that you can be used for Joining Tables in Tableau. They are inner Join, Left Join, Right Join, and full outer Join.
Connecting to Multiple Tables in Tableau
- Select the table or view you want to start with (typically the fact table) and then select the Multiple Tables option
- Click the Add New Table button at the bottom of the dialog box.
- In the Add Table dialog box, select a table to add to the Data window.
- Optionally change Field aliases.
In the bottom half of the Add Table dialog box, there is a list of fields with their aliases. Double-click the field alias to change how the field will be displayed in the Data window. This is often useful when you have duplicate field names across tables or your field names are not very understandable.
- Add a join by selecting the Join tab.
Tableau will automatically create a join for you based on the structure of your data. Select the Joins tab to inspect the join clause to make sure it is how you want to connect the tables. You can delete unwanted join clauses by selecting it in the list of join clauses and clicking Delete.
- In the Join pane, add one or more join clauses by selecting a field from the original table, a field from the added table, and an operator. Then click Add to add it to the list of Join Clauses.
For example, in a data source that has a table of order information and another for users information, you could join the two tables based on the Region field that exists in both tables. Select Region in both the lists of fields, select the equal sign as the operator, and click Add.
- Select the type of Join from the Join Type drop-down list.
- You can select Inner, Left, or Right.
Please note, you cannot nest Inner joins within Left or Right joins. These joins will cause a join expression not supported error.
- When finished, click OK.
The tables are listed in the Connection dialog box along with the foreign keys. Complete the connection by giving it a name and clicking OK. When you add joined tables, the Data window is automatically organized to use the Group by Table command. You can turn this feature off or change how the Data window is sorted using the Data window menu.