How to join data sources in Tableau
By the Analistable team · Updated · 5 min read
In Tableau's Data Source page, drag a second table next to the first to create a relationship — the default since Tableau 2020.2, which joins at the right level for each view. To force a classic join, double-click a table to open the physical layer and drag the second table in there; tables from different connections (Excel and a database, say) join the same way as a cross-database join. Use a blend only when sources can't be combined on the Data Source page.
Part of our guide: How to merge data in Power BI, Power Query and Tableau
Relationships, joins, unions and blends
| Method | Where | Result | Use when |
|---|---|---|---|
| Relationship | Logical layer (the default canvas) | Tables stay separate; joined per view | Most cases, especially different levels of detail |
| Join | Physical layer (double-click a table) | One flat table | You need a fixed, row-level combined table |
| Cross-database join | Physical layer, two connections | One flat table from two sources | Joining Excel with a database or CSV |
| Union | Physical layer | Rows stacked | Same columns split across files or sheets |
| Blend | Worksheet (secondary source) | Aggregated secondary data linked on common fields | Sources that can't be joined or related |
Create a relationship
- Connect to the first source and drag a table onto the canvas.
- Drag the second table onto the canvas. Tableau draws a line (a “noodle”) between them.
- In the relationship dialog, choose the matching fields (for example Orders.Customer ID = Customers.Customer ID).
- Build a view. Tableau decides the join type per view, so measures from Orders aren't duplicated by repeated customer rows.
Create a join or cross-database join
- On the Data Source page, add a second connection if the table is in another file or database (Add next to Connections).
- Double-click the first table on the canvas to open its physical layer.
- Drag the second table into that area. Choose Inner, Left, Right or Full Outer and set the join clause.
Joins duplicate rows when keys repeat, so a SUM of order amounts can double after joining to a table with two rows per customer. Check row counts with the data grid at the bottom of the page.
Blending
Drag a field from the primary source into the view, then select the secondary source in the Data pane. Fields linked by name show an orange chain icon; click it to turn a link on or off. The secondary source is aggregated to the level of the linking fields before it's combined, which is why blends can't show row-level detail from the secondary source.
The same concepts in Power BI and Power Query are covered in merging data in Power BI and Tableau.
Worked example: why relationships avoid double counting
Orders has 4 rows totalling 335 (O-1 120, O-2 75, O-3 80, O-4 60) for customers C-1, C-3, C-1 and C-4. A Targets table has two rows per customer, one per half-year. Joined in the physical layer on Customer ID, each order appears twice for every customer that has targets:
| Method | Rows in combined table | SUM(Amount) |
|---|---|---|
| Inner join Orders–Targets (targets for C-1 and C-3) | 6 | 550 (120, 80 and 75 each counted twice) |
| Relationship Orders–Targets | Not flattened | 335 (Orders measures stay at order level) |
The inner join gives (120 + 80 + 75) × 2 = 550 and drops C-4's order of 60. The relationship gives the true 335 because Tableau queries Orders at its own level before combining. When you must use a join, fix this with a FIXED level-of-detail calculation or aggregate the many-side table before joining.
Unions for files with the same columns
- On the Data Source page, connect to the first file.
- Drag New Union from the left pane onto the canvas (in the physical layer).
- Add tables manually, or choose Wildcard (automatic) to include every sheet or file that matches a pattern such as
sales_*.csvin a folder. - Tableau adds fields such as Path, Sheet or Table Name that record where each row came from.
Columns are matched by name; a field that is spelled differently in one file appears as two fields. Right-click and choose Merge Mismatched Fields to combine them. Wildcard unions pick up new matching files when the extract is refreshed.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| Totals are inflated | A physical join repeated rows | Use a relationship, or LOD calculations |
| Nulls for most fields from the second table | Key types differ (string vs number) or values are formatted differently | Change the field type, or relate on a calculated field that cleans the key |
| Blend shows an asterisk (*) | Several secondary values for one primary value | Add the linking field to the view or link on more fields |
| Slow dashboards with cross-database joins | The join runs in Tableau after pulling both sources | Use an extract, or join in the database |
Which method to choose
- Start with relationships. They handle different levels of detail and unmatched values on either side without manual join types.
- Use a join when a calculation genuinely needs the row-level combined table, such as a field computed from columns in both tables.
- Use a union for monthly or regional files with the same layout.
- Use a blend for published data sources you can't edit, or a quick comparison against an aggregated secondary source.
If the data still lives in spreadsheets, it is often simpler to combine it before it reaches Tableau; joining spreadsheets covers the options.
Frequently asked questions
- What's the difference between a relationship and a join in Tableau?
- A join creates one flat table in advance. A relationship keeps tables separate and joins them at the right level for each view, which avoids duplicated measures.
- Can Tableau join an Excel file with a database?
- Yes. Add both connections on the Data Source page and join the tables in the physical layer (a cross-database join).
- When should I use data blending?
- When the sources can't be related or joined on the Data Source page, for example published data sources, or when the secondary data only needs to be aggregated.
- Why did my totals double after joining tables in Tableau?
- The physical join repeated rows because the key appears more than once in one table. Use a relationship in the logical layer instead, or aggregate that table before joining.