Tableau Joins

What are Tableau Joins?

When there is a need to view the features of different datasets in a consolidated database, be it in different types, matched, or mismatched, we use Tableau Joins. Tableau joins are used to join two data sources to view their features similarly and also perform visualizations if needed. There are several types of joins you can use, each serving different purposes and resulting in different data sets.

Here is an example depicting how to make Tableau database joins.

Tableau Joins - Intro

Here, we create the Tableau joins in database using inner join with the same database, but different worksheets. Here, we acquire all these tables from the Bookshop database.

Key Takeaways
  • Tableau allows users to combine data from multiple sources using joins, enabling comprehensive analysis and visualization.
  • Users can perform different types of joins, including inner joins, left joins, right joins, and full outer joins, to merge data based on common fields.
  • Joining data in Tableau is intuitive, with a drag-and-drop interface that simplifies the process without requiring complex coding or scripting.
  • Users can visualize joined data seamlessly, creating unified views that incorporate information from multiple sources.
  • Tableau’s join capabilities support various data sources, including databases, spreadsheets, cloud services, and web data connectors, facilitating versatile analysis.

Types And Applications

There are four main types of Tableau Database joins possible. They are explained in detail.

#1 – Inner Join

Tableau Joins - Inner Join

This connects both databases on 1 common feature and includes only the values that are common or equal in both databases. The other values are ignored.

Example: If Table A and Table B have a standard column “ID,” an inner join will include only the rows where “ID” values match in both tables.

#2 – Left Join

Tableau Joins - Left Join

The Left Join or the Left Outer join is used to connect the databases where all the values from the left table, that is, the first table included have all the values, but, only the matching values from the right table are included. Values without matches are returned as nulls in the right table.

Example: If Table A is the left table and Table B is the right table, a left join will include all rows from Table A and the matched rows from Table B. Unmatched rows in Table B will have NULLs.

#3 – Right Join

Tableau Joins - Right Join

Similar to the left join, in the Right Join or Right Outer Join, all the values from the right table, that is, the table added after the default table in Tableau, are included. Only the matching values are included in the left table. Values with no matches are depicted as nulls in the left table.

Example: If Table A is the left table and Table B is the right table, a right join will include all rows from Table B and the matched rows from Table A. Unmatched rows in Table A will have NULLs.

#4 – Full Outer Join

Tableau Joins - Full Outer Join

The functionality is similar to Right Join or Left Join. The only difference is that all values from both tables are included in this join. Any values with no matches from either side of the table are shown as nulls.

Example: If Table A and Table B have a common column “ID”, a full join will include all rows from both tables, with NULLs in places where there are no matches.

In this way, you can see three ways to use the Outer Join Tableau methods.

#5 – Union

Tableau Joins - Union

It is not part of the Tableau Joins case-sensitive method, but it is also used to combine databases by appending the rows of the datasets in a table. You can create new unions in Tableau in a simple manner by clicking on “New Union” in the “Data Source” tab.

Tableau Joins - New Union

How to create a Join in Tableau?

We create the Tableau Database joins as shown.

Step 1: In the Tableau Public application, click on “File” and then “New” to create a new Tableau workbook.

Tableau Joins - create - Step 1

It will open a new workbook with a default sheet available.

Step 2: Connect to a data source by clicking on “Ctrl+D” in your workbook. Then, it opens your local storage, where you can navigate and select your database.

Tableau Joins - create - Step 2

You can also drag and drop the file you need. The “books.csv” file is used.

Step 3: Go to the “Data Source” tab to view the database. The “books.csv” file is shown.

Tableau Joins - create - Step 3

Step 4: Right-click on the database and select “Open.”

Tableau Joins - create - Step 4

Step 5: Inside the table, drag and drop the database “ratings.csv” from the “Files” section. Tableau shows files similar to the data source you have integrated from your local storage to help make things easier.

Tableau Joins - create - Step 5

The inner join is done by default if dragged and dropped and is the combined database view.

Tableau Joins - create - Step 5 - inner join table

Miscellaneous: Drag and drop the file “users.csv”. But you can see that it isn’t working because Tableau cannot detect any common files on its own. 

Tableau Joins - create - Step 5 - Miscellaneous

In such cases, you can either remove the join or manually define it.

Examples

Learn more about the techniques and the different ways to perform the Tableau Database Joins. The examples below provide a simple demonstration of how it can be used.

Example #1: Edit a Join Type in Tableau

Consider that you have two separate datasets. One contains the books available on Amazon, and the other has ratings for the different books available. You want to see the total number of ratings for each of the books on Amazon in a visualization. It can be done by joining the databases and then performing the necessary visualizations.

Step 1: In a new workbook, drag and drop the “books.csv” dataset.

Tableau Joins - create - Step 3

Step 2: Open the dataset to join the tables from different datasets. This is done by right-clicking on “books.csv” and then selecting “Open.”

Tableau Joins - create - Step 4

Step 3: Drag and drop “ratings.csv” from the “Files” tab in Tableau. Note that both the files should remain in the same directory, or else you may need to add new connections, which doesn’t give you the choice of the type of join that you want.

Tableau Joins - create - Step 5

Step 4: Click on the “Join” icon in between “books.csv” and “ratings.csv” and select “Right Join”.

Tableau Joins - Example 1 - Step 4

The common features are declared by default in Tableau.

Step 5: Check in the Data Source view whether the “Right Join” has been done successfully. Since it is a Right Outer Join, all the features from “ratings.csv” will be included. Only the matching values in “ratings.csv” will be shown in “books.csv.” The unmatched values will be shown as “NULL.”

Tableau Joins - Example 1 - Step 5

If you open the “ratings.csv” file, you can see that all the features (not only the common features) are included.

Tableau Joins - Example 1 - Step 6

Step 6: Go to “Sheet1”, the default sheet in a new workbook, to start with your calculations. You can see the dimensions and measures defined for both databases.

Tableau Joins - Example 1 - Step 6 - Tables

Step 7: Place “Book-Title” from “books.csv” in the “Rows” tab.

Tableau Joins - Example 1 - Step 7

Step 8: Place the “Book-Rating” value in the “Columns” tab.

Tableau Joins - Example 1 - Step 8

Step 9: Drag and drop the “Book-Author” in the “Filter” tab. This is done to remove all the null values. Since this is a right join, the mismatched values are depicted as NULL values. This may harm the visualization that you’re trying to do. Click on “Null” in the popup and click “Exclude.”

Tableau Joins - Example 1 - Step 9

Step 10: Click on this icon in the graph to sort the visualization in descending order.

Tableau Joins - Example 1 - Step 10 - Descending

It is the graph made from joining both databases via right join.

Tableau Joins - Example 1 - Step 10 - Graph

Example #2: Edit Join Fields in Tableau

Suppose you have two databases that you want different common features from the default features that Tableau has pronounced, how do you do that? By editing the Join Fields in Tableau, you can drastically change the result. You can do this by following these steps. Here is the number of reviews from different cities in America for each Airbnb. The cities in question are Albany, New York, and Austin, Texas.

Step 1: Drag and drop the Airbnb dataset of Austin, Texas, in a new workbook.

Tableau Joins - Example 2 - Step 1

Step 2: Right-click on the dataset and select “Open.”

Tableau Joins - Example 2 - Step 2

Step 3: Place the Airbnb dataset of Albany, New York, by dragging and dropping it next to the Austin dataset.

Tableau Joins - Example 2 - Step 3

If you click on the join symbol, you can see the common feature that Tableau has automatically chosen.

Tableau Joins - Example 2 - Step 3 - join symbol

You can see that there is no Tableau joins case-sensitive features. The feature heading joins are mostly case-insensitive unless specified.

Step 4: Click on the join fields to select the field of your choice to be joined.

Example 2 - Step 4

The field chosen is the “Number of Reviews” for both datasets.

Tableau Joins - Example 2 - Step 4 - number of reviews

Step 5: View the joins in the data view in the “Data Source” tab.

Tableau Joins - Example 2 - Step 5
Tableau Joins - Example 2 - Step 5 - NYAirbnb

Only the common values from both datasets are chosen.

Step 6: Select the year when the “last review” was made. Place that in the “Columns.” Then, place both the “minimum nights” feature from both datasets.

Tableau Joins - Example 2 - Step 6

Step 7: Click on “Show Me” in the top-right corner of the worksheet and select “side-by-side bars.”

Example 2 - Step 7

Step 8: Right-click on the “Null” field in the X-axis and select “Exclude.”

Tableau Joins - Example 2 - Step 8

It is the final graph.

Tableau Joins - Example 2 - Step 8 - graph

The colors indicate the dataset from which they were taken.

Tableau Joins - Example 2 - Step 8 - colors

Example #3

In this example, you can learn how to join tables from different worksheets in the same database and gain insights from them. Here, the “Bookshop” dataset is used.

Step 1: Drag and drop the “Bookshop” dataset.

Example 3 - Step 1

The available worksheets are shown in the “Files” tab.

Example 3 - Step 1 - worksheets

Step 2: Drag and drop “Book” from the files.

Example 3 - Step 2

Step 3: Right-click on “Book” and select “Open.”

Example 3 - Step 3

Step 4: In the tab, drag and drop “Author,” “Award,” and “Edition” from the files. All three worksheets are joined using “inner join.”

Tableau Joins - Example 3 - Step 4

Step 5: Go to the first worksheet to perform your visualization. Select the features from the following tables to create the visualization. The black mark is used in columns, and the red ones are used in rows.

Example 3 - Step 5

Step 6: Place “Title” in the “Columns” and place the “Hrs Writing per Day,” “Pages,” and “Price” in the “Rows.”

Example 3 - Step 6

Step 7: In the top-right-hand corner, click on “Show Me” and select “side-by-side bars.”

Example 3 - Step 7

It is the graph we obtain when we join two tables with the “Books” table.

Tableau Joins - Example 3 - Step 7 - Graph
Example 3 - Step 7 - names

Important Things To Note

  • Ensure you understand the structure and relationships within your data before creating joins.
  • Inner joins are efficient for filtering data to include only matching records.
  • Double-check if the join conditions are correct and that join keys are appropriately indexed.
  • Avoid using outer joins in excess, as they can result in large datasets and performance issues.
  • Ensure the data types of join keys match to avoid errors and unexpected results.
  • Only join tables that are essential for your analysis to keep the data model simple.

Frequently Asked Questions (FAQs)

1. What is the difference between Relationships and Joins in Tableau?

FAQ 1

2. What is the difference between Blends and Joins in Tableau?

FAQ 2

3. What is the difference between Unions and Joins in Tableau?

Let us look at some of the differences.

Unions

It combines data by appending rows from two or more tables.
Unions require tables to have the same number of columns and compatible data types.
There is a vertical stacking of rows.
It is helpful for adding similar datasets, such as monthly sales data.
Tables must have identical or very similar schemas.

Joins

It combines data by merging columns based on a common field.
It can join tables with different structures as long as there is a common field.
There is a horizontal merging of columns.
It is helpful for combining related datasets, such as customer and order information.

4. How many maximum tables can you join in Tableau?

There isn’t a fixed limit for the number of tables that you can join in Tableau. There are several factors in play when it comes to determining the number of tables that you can join in Tableau. They are:

1. Fixed Limit
2. System Resources
3. Complexity of Joins
4. Data Volume

Download Template

This article must be helpful to understand the Tableau Joins, with its formula and examples. You can download the template here to use it instantly.

This has been a guide to Tableau Joins. Here we learn different ways to perform the Tableau Database Joins with examples, types & applications and points to remember. You can learn more from the following articles –

Reader Interactions

Leave a Reply

Your email address will not be published. Required fields are marked *