Analistable

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

Ways to combine data in Tableau
MethodWhereResultUse when
RelationshipLogical layer (the default canvas)Tables stay separate; joined per viewMost cases, especially different levels of detail
JoinPhysical layer (double-click a table)One flat tableYou need a fixed, row-level combined table
Cross-database joinPhysical layer, two connectionsOne flat table from two sourcesJoining Excel with a database or CSV
UnionPhysical layerRows stackedSame columns split across files or sheets
BlendWorksheet (secondary source)Aggregated secondary data linked on common fieldsSources that can't be joined or related

Create a relationship

  1. Connect to the first source and drag a table onto the canvas.
  2. Drag the second table onto the canvas. Tableau draws a line (a “noodle”) between them.
  3. In the relationship dialog, choose the matching fields (for example Orders.Customer ID = Customers.Customer ID).
  4. 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

  1. On the Data Source page, add a second connection if the table is in another file or database (Add next to Connections).
  2. Double-click the first table on the canvas to open its physical layer.
  3. 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:

SUM(Amount) by method
MethodRows in combined tableSUM(Amount)
Inner join Orders–Targets (targets for C-1 and C-3)6550 (120, 80 and 75 each counted twice)
Relationship Orders–TargetsNot flattened335 (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

  1. On the Data Source page, connect to the first file.
  2. Drag New Union from the left pane onto the canvas (in the physical layer).
  3. Add tables manually, or choose Wildcard (automatic) to include every sheet or file that matches a pattern such as sales_*.csv in a folder.
  4. 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 and fix
SymptomCauseFix
Totals are inflatedA physical join repeated rowsUse a relationship, or LOD calculations
Nulls for most fields from the second tableKey types differ (string vs number) or values are formatted differentlyChange the field type, or relate on a calculated field that cleans the key
Blend shows an asterisk (*)Several secondary values for one primary valueAdd the linking field to the view or link on more fields
Slow dashboards with cross-database joinsThe join runs in Tableau after pulling both sourcesUse 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.

Related guides