In many projects the data is not all in one table. You often have different tables for different things.
- One table has events or sales (like flights, tickets, orders).
- Another table has extra information (like seat loads, targets, customers).
If you look at them separate, you don’t see the whole story. You need to join them together. A join is simply a way to combine two tables into one.
If you used SQL before, the idea is the same. The only difference is in Tableau Prep you can drag and drop instead of writing code.
What is a Join?
A join connects rows from two tables using one or more columns that have the same type of data. These columns are called keys.
Example:
- Flights Table → has flight details (
Flight Number,Month,Class,Price) - Targets Table → has targets per month and class (
Month,Class,Load %)
Both tables have Month and Class. If you join on these fields, you can add the target value to each flight.
Types of Joins in Tableau Prep
When you create a join in Prep, you see a Venn diagram. There are four types:
1. Inner Join
- Keeps only rows that match in both tables.
2. Left Join
- Keeps all rows from the left table. Adds data from the right if it matches.
3. Right Join
- Keeps all rows from the right table. Adds data from the left if it matches.
4. Full Outer Join
- Keeps all rows from both tables. Missing values show as
NULL.
Picking Good Join Keys
The join key is very important. It is the thing that connects rows from both tables.
Good keys:
- Must exist in both tables.
- Must mean the same thing. (
Customer IDtoCustomer IDis good.Customer IDtoBooking IDis wrong.) - Must be at the right level.
- Want per customer? Use
Customer ID. - Want per flight? Use
Flight Number + Date. - Want per class per month? Use
Month + Class.
- Avoid many-to-many joins. They can create extra rows you don’t want.
Example: Flights + Seat Loads
Flights Table
| Month | Class | Flight | Price |
|---|---|---|---|
| 10 | BC | PA005 | 960 |
| 10 | EC | PA009 | 700 |
Loads Table
| Month | Class | Load % |
|---|---|---|
| 10 | BC | 39 |
| 10 | EC | 18 |
Correct join key: Month + Class
| Month | Class | Flight | Price | Load % |
|---|---|---|---|---|
| 10 | BC | PA005 | 960 | 39 |
| 10 | EC | PA009 | 700 | 18 |
Wrong join key: Month only
| Month | Flight | Price | Class (Flights) | Class (Loads) | Load % |
|---|---|---|---|---|---|
| 10 | PA005 | 960 | BC | BC | 39 |
| 10 | PA005 | 960 | BC | EC | 18 |
| 10 | PA009 | 700 | EC | BC | 39 |
| 10 | PA009 | 700 | EC | EC | 18 |
Here you see every flight matched with both classes. Extra rows appear that should not exist.
How to Check in Tableau Prep
Prep helps you see if something is wrong:
- The join step shows how many rows matched and how many did not.
- If too many unmatched rows → maybe wrong key.
- If row count is much bigger than expected → probably a many-to-many join.
Always check the join results before moving forward.
Summary
- Joins combine data from different tables.
- The join type decides which rows stay.
- The join key decides how rows match.
- Wrong keys can create too many rows.
- Always check your join in Tableau Prep to be sure it makes sense.
