Unions, Joins, and Data Relationships in Tableau
Definition: Unions, joins, and data relationships are techniques used in Tableau to combine data from multiple tables. A union adds rows from similar tables, a join combines columns from tables using matching fields, and a relationship defines how separate tables are connected for analysis without merging them into one fixed table.
Example: A company has sales records for 2025 and 2026, customer details, and product information. A union can combine the yearly sales records, a join can combine sales and customer columns, and a relationship can connect sales, customer, and product tables for flexible analysis.
Course: JustAcademy Tableau Training
Course Demo: Register for a Tableau Course Demo
1. Understanding Data Combination in Tableau
Business data is often stored in multiple tables, files, or database systems. Tableau allows you to combine these data sources so you can analyze information together.
For example, an organization may maintain separate tables for sales, customers, products, and regions. Combining these tables helps answer questions such as which products generate the highest sales, which customers contribute the most revenue, and which regions perform best.
Tableau provides several ways to combine data. The most appropriate method depends on the structure of the tables, their level of detail, and the desired analytical result.
- Union: Adds rows from one table to another.
- Join: Combines columns from tables using a matching condition.
- Relationship: Defines a logical connection between tables and allows Tableau to combine relevant data based on the visualization.
2. What Is a Union in Tableau?
A union combines rows from two or more tables that have similar structures. It stacks the records vertically, allowing data from multiple files or tables to be analyzed as one dataset.
Unions are useful when different tables contain the same types of information for different periods, regions, departments, or business units.
Example: Sales Data for Two Years
Sales 2025
| Order ID |
Product |
Sales |
| 101 |
Laptop |
50000 |
| 102 |
Mobile |
30000 |
Sales 2026
| Order ID |
Product |
Sales |
| 103 |
Tablet |
20000 |
| 104 |
Monitor |
15000 |
Result after Union
| Order ID |
Product |
Sales |
| 101 |
Laptop |
50000 |
| 102 |
Mobile |
30000 |
| 103 |
Tablet |
20000 |
| 104 |
Monitor |
15000 |
The union combines the records vertically. It does not match Order ID values across the two tables.
When Should You Use a Union?
- When multiple files contain the same type of data.
- When combining monthly, quarterly, or yearly records.
- When combining records from different branches or regions with similar columns.
- When adding new rows to an existing dataset.
How to Create a Union in Tableau Desktop
- Open Tableau Desktop and connect to your data source.
- Open the Data Source page.
- Drag the first table or file onto the canvas.
- Open the table's physical layer by double-clicking the logical table.
- Drag another compatible table into the physical layer until the Union option appears.
- Drop the table into the union area.
- Review the combined data in the preview grid.
- Verify the column names, data types, and row count.
Note: Tableau may automatically match columns with the same names. Columns that do not match may still be included as separate fields, with null values for records where that field is unavailable. Check the results before analysis.
Types of Unions
- Manual Union: You select the tables or sheets to combine.
- Wildcard Union: Tableau matches tables or files based on a naming pattern, where supported. This is useful when new files follow a consistent naming convention.
Example: Files named Sales_January, Sales_February, and Sales_March can be combined using a suitable wildcard pattern when the connection supports it.
Advantages of Unions
- Combines similar datasets quickly.
- Supports analysis across multiple time periods.
- Reduces the need to analyze each file separately.
- Can simplify reporting when the tables share a consistent structure.
Limitations of Unions
- Unions are most useful when the tables have compatible structures.
- Different column names can lead to separate fields rather than the intended combined field.
- Different data types may require cleaning or conversion.
- A union does not automatically match related records between tables.
3. What Is a Join in Tableau?
A join combines columns from two tables using one or more matching conditions. The resulting rows contain fields from both tables.
Joins are useful when the tables share a key, such as Customer ID, Product ID, or Order ID, and you need to combine their information into one table.
Example: Orders and Customers
Orders Table
| Order ID |
Customer ID |
Sales |
| 1001 |
C01 |
25000 |
| 1002 |
C02 |
18000 |
| 1003 |
C03 |
30000 |
Customers Table
| Customer ID |
Customer Name |
City |
| C01 |
Amit |
Mumbai |
| C02 |
Priya |
Pune |
| C03 |
Rahul |
Delhi |
Result after Join
| Order ID |
Customer ID |
Sales |
Customer Name |
City |
| 1001 |
C01 |
25000 |
Amit |
Mumbai |
| 1002 |
C02 |
18000 |
Priya |
Pune |
| 1003 |
C03 |
30000 |
Rahul |
Delhi |
The join adds customer details to each matching order record using Customer ID.
Common Join Types
A. Inner Join
An inner join returns rows where the join condition matches in both tables.
Example: If an order has a Customer ID that does not exist in the Customers table, that order is excluded from the inner-join result.
B. Left Join
A left join returns all rows from the left table and matching rows from the right table. If there is no match in the right table, its fields contain null values.
Example: Keep all Orders records even when customer details are missing.
C. Right Join
A right join returns all rows from the right table and matching rows from the left table. If there is no match in the left table, its fields contain null values.
D. Full Outer Join
A full outer join returns matching rows and unmatched rows from both tables. Fields from the table without a match contain null values.
Join Types Comparison
| Join Type |
Records Included |
Typical Use |
| Inner Join |
Matching records from both tables |
Analyze only records with matching keys |
| Left Join |
All left-table records and matching right-table records |
Keep every order, even when customer details are missing |
| Right Join |
All right-table records and matching left-table records |
Keep every customer in the right table |
| Full Outer Join |
All records from both tables, matched where possible |
Identify matches and unmatched records on either side |
How to Create a Join in Tableau Desktop
- Connect Tableau to your data source.
- Open the Data Source page and drag a table onto the canvas.
- Double-click the logical table to open the physical layer.
- Drag the second table into the physical layer beside the first table.
- Click the join icon between the tables.
- Choose the join type: Inner, Left, Right, or Full Outer.
- Select the matching fields, such as Customer ID in both tables.
- Review the join preview and check for unmatched records or duplicate rows.
- Open a worksheet and verify the totals and record counts.
Advantages of Joins
- Combines related information into one table.
- Allows explicit control over join types and matching conditions.
- Works well when the analysis requires a fixed, combined row structure.
- Can be useful for preparing a single logical table for particular analysis or extract requirements.
Limitations of Joins
- Unmatched records may be excluded depending on the join type.
- One-to-many or many-to-many matches can duplicate rows.
- Duplicated rows can inflate totals or counts if not handled correctly.
- Join conditions and join types are fixed in the data model rather than selected dynamically for each visualization.
4. What Are Data Relationships in Tableau?
A relationship defines how two tables are connected using common fields without merging them into one fixed table. Tableau keeps the tables separate in the logical layer and determines how to combine their data based on the fields used in a worksheet.
Relationships were introduced in Tableau 2020.2 as part of its enhanced data model. They are generally the recommended starting point for combining tables in modern Tableau versions because they preserve each table's level of detail and let Tableau adapt the queries to the analysis.
Example: Sales, Customers, and Products
Suppose a business has three tables:
| Sales Table |
Customers Table |
Products Table |
| Order ID |
Customer ID |
Product ID |
| Customer ID |
Customer Name |
Product Name |
| Product ID |
City |
Category |
| Sales Amount |
Region |
Unit Price |
You can relate Sales to Customers through Customer ID and Sales to Products through Product ID. Tableau can then analyze sales by customer city or product category without requiring the tables to be permanently merged into a single joined table.
How Relationships Work
- Tables remain separate in the logical layer.
- You define relationships by choosing matching fields.
- You do not choose a fixed join type when defining a relationship.
- Tableau uses the fields in the visualization to determine how to query the related tables.
- Each table retains its own level of detail.
- Tableau can aggregate data from each table appropriately, helping reduce duplication problems caused by joins.
How to Create a Relationship in Tableau Desktop
- Connect Tableau to the first data table.
- Open the Data Source page.
- Drag the first table onto the logical layer canvas.
- Drag the second table onto the canvas beside the first table.
- Tableau creates a relationship line between the tables.
- Click the relationship line to edit the relationship.
- Select the matching field in each table, such as Customer ID.
- Confirm that the matching fields have compatible data types.
- Review any relationship options available for cardinality and referential integrity, and keep the defaults unless you understand the data well enough to change them.
- Open a worksheet and use fields from both tables to verify the analysis.
Advantages of Relationships
- Tables remain separate rather than being merged in advance.
- Useful when tables have different levels of detail.
- Tableau selects appropriate joins according to the fields in the visualization.
- Can help avoid duplicated measures that may occur with joins.
- Supports flexible analysis across multiple tables in a data source.
- Can reduce unnecessary queries because Tableau queries tables relevant to the current view.
Limitations and Considerations
- Relationship fields should have compatible data types.
- Incorrect relationship fields can produce misleading results.
- Unmatched values and aggregation behavior still need to be understood and checked.
- Dirty data, inconsistent keys, or unclear levels of detail can complicate analysis.
- Relationships do not replace joins in every scenario. Use a join when you specifically need a fixed, merged table or explicit join behavior.
5. Unions vs. Joins vs. Relationships
| Feature |
Union |
Join |
Relationship |
| Main purpose |
Add rows |
Combine columns using matching conditions |
Define a logical connection between tables |
| Data direction |
Vertical |
Horizontal |
Logical connection; tables remain separate |
| Matching fields required |
No key match required; compatible column structures are useful |
Yes, a join condition is required |
Yes, matching relationship fields are required |
| Output structure |
Rows from multiple tables in one logical table |
A merged table with fields from both tables |
Separate logical tables connected in the data model |
| Join type selection |
Not applicable |
Explicitly selected |
Not selected up front; Tableau determines join behavior in analysis |
| Typical use |
Combining monthly sales files |
Adding customer details to orders |
Analyzing sales and customers at different levels of detail |
| Potential risk |
Columns may not align as expected |
Rows may be duplicated or unmatched records excluded |
Incorrect relationship fields or misunderstood aggregation can produce unexpected results |
6. Understanding Logical and Physical Layers
Modern Tableau data sources have two main layers in the data model.
Logical Layer
The logical layer is the top-level canvas on the Data Source page. You create relationships between logical tables here. Each logical table can contain one or more physical tables.
Physical Layer
The physical layer appears when you open a logical table. You can use joins and unions to combine physical tables inside that logical table.
Important distinction: Relationships connect logical tables in the logical layer. Joins and unions operate on physical tables in the physical layer.
Simple Data Model Example
Logical Layer:
Customers ───── Relationship ───── Sales
|
Relationship
|
Products
Physical Layer inside a logical table:
Sales_2025 ───── Union ───── Sales_2026
This example shows that sales files for two years can be unioned into one logical table, which can then be related to Customers and Products.
7. Choosing the Right Method
- Choose a union when you want to append rows from tables with similar structures.
- Choose a join when you need a fixed table containing columns from multiple tables and you know the correct matching conditions.
- Choose a relationship when you want to analyze multiple tables while preserving their different levels of detail.
Best practice: Tableau recommends starting with relationships for multi-table analysis and using joins when you specifically need the behavior of a fixed merged table. A union is appropriate when the task is to append records rather than match related records.
8. Common Problems and Troubleshooting
| Problem |
Possible Cause |
Solution |
| Duplicate sales totals after a join |
Multiple matching records or tables at different levels of detail |
Check key uniqueness and the number of matching rows; consider a relationship if appropriate |
| Some records are missing |
An inner join excludes unmatched rows, or the join keys do not match |
Check join type, key values, data types, and unmatched records |
| Null values appear after a join |
Some records have no matching row on the other side |
Inspect join keys and decide whether the chosen join type is appropriate |
| Union creates separate fields for similar information |
Column names differ across the source tables |
Standardize column names or map the fields consistently before combining |
| Union results have nulls |
Some source tables lack columns present in other tables |
Review column structure and ensure the output is expected |
| Relationship results seem incorrect |
Wrong relationship fields, incompatible data types, or misunderstood aggregation |
Verify relationship keys and test the results with simple views |
| Totals differ between a join and relationship |
Joins and relationships handle row-level detail and aggregation differently |
Compare the level of detail, matching keys, and aggregation behavior |
| New files are not included in a union |
The union was defined manually or the file naming pattern does not match |
Review the union configuration and use a wildcard union where supported |
9. Best Practices for Combining Data
- Understand the purpose and structure of every table before combining it.
- Use unions when tables contain similar columns and you need more rows.
- Use joins when you need a fixed combination of columns and explicit matching behavior.
- Use relationships as the starting point for flexible multi-table analysis.
- Check key fields for duplicates, nulls, and inconsistent formatting.
- Confirm that join and relationship fields use compatible data types.
- Validate row counts and totals before and after combining data.
- Check for one-to-many and many-to-many relationships before joining tables.
- Do not assume that matching column names guarantee matching data.
- Document the reason for each union, join, or relationship.
- Test the resulting data with simple tables before building complex dashboards.
10. Practical Exercise
Task: Combine sales data from two years and connect it to customer information for analysis.
Sample Sales Data: 2025
| Order ID |
Customer ID |
Product |
Sales |
| 101 |
C01 |
Laptop |
50000 |
| 102 |
C02 |
Mobile |
30000 |
Sample Sales Data: 2026
| Order ID |
Customer ID |
Product |
Sales |
| 103 |
C01 |
Tablet |
20000 |
| 104 |
C03 |
Monitor |
15000 |
Sample Customer Data
| Customer ID |
Customer Name |
City |
| C01 |
Amit |
Mumbai |
| C02 |
Priya |
Pune |
| C03 |
Rahul |
Delhi |
Instructions
- Connect Tableau to the sales files for 2025 and 2026.
- Create a union to append the sales records.
- Connect or add the customer table.
- Create a relationship between the combined Sales table and Customers using Customer ID.
- Open a worksheet and create a view of Sales by City.
- Check that sales totals are correct and that customers with matching records are associated with the correct cities.
- Compare the results with a join-based version if you want to understand the difference in behavior.
Expected Learning Outcome
You should be able to distinguish between adding rows with a union, combining columns with a join, and defining logical connections with relationships.
11. Interview Questions and Answers
Q1. What is a union in Tableau?
A union appends rows from two or more tables into a combined dataset.
Q2. What is a join in Tableau?
A join combines columns from two tables using a matching condition and a selected join type.
Q3. What is a relationship in Tableau?
A relationship defines how separate tables are connected. Tableau uses the relationship and the fields in the visualization to determine how to query the data.
Q4. What is the difference between a union and a join?
A union adds rows vertically, while a join combines columns horizontally based on matching conditions.
Q5. What is the difference between a join and a relationship?
A join merges physical tables into one fixed table. A relationship keeps logical tables separate and allows Tableau to determine how to combine their data during analysis.
Q6. What is an inner join?
An inner join returns only rows where the join condition matches in both tables.
Q7. What is a left join?
A left join returns every row from the left table and matching rows from the right table. Nonmatching right-table fields contain null values.
Q8. Why can joins produce duplicate records?
If a key matches multiple rows in the other table, the join can produce multiple output rows for that record, potentially duplicating measures when aggregated.
Q9. When should you use relationships?
Use relationships when you need flexible analysis across multiple tables, especially when the tables have different levels of detail.
Q10. What is the difference between the logical and physical layers?
The logical layer connects tables through relationships. The physical layer contains the tables combined through joins or unions.
Q11. What is a wildcard union?
A wildcard union combines files or tables whose names match a specified pattern, where supported by the connection.
Q12. Which method should you try first for multi-table analysis?
Relationships are generally the recommended starting point. Use joins when a fixed merged table is specifically required and unions when you need to append rows.
12. Quick Revision Checklist
- Understand the purpose of unions, joins, and relationships.
- Remember that unions add rows vertically.
- Remember that joins combine columns horizontally using matching conditions.
- Know the differences between inner, left, right, and full outer joins.
- Understand that relationships keep logical tables separate.
- Know how to create unions in the physical layer.
- Know how to create joins in the physical layer.
- Know how to define relationships in the logical layer.
- Understand logical tables and physical tables.
- Check for unmatched keys, duplicate rows, and unexpected nulls.
- Validate totals and record counts before building dashboards.
13. Learning Resources
Conclusion
Unions, joins, and relationships are essential Tableau data modeling techniques. Unions append records from similar tables, joins combine columns using explicit matching conditions, and relationships connect tables for flexible analysis while preserving their individual levels of detail. Choosing the correct method and validating the results helps prevent missing records, duplicated measures, and inaccurate dashboards.