Unioning Data in Tableau
Learn how to combine multiple tables by adding rows using Tableau Unions. Understand manual unions, wildcard unions, data structure requirements, practical examples, and common union errors.
1. What is Unioning Data in Tableau?
Unioning is a data-combination technique in Tableau that combines multiple tables by adding their rows into a single table. It is useful when different tables contain similar types of information and have the same or compatible column structures.
Unlike joins, which combine columns from different tables based on matching fields, unions append rows from one table below another. The resulting table contains records from all the participating tables.
Key Characteristics of Union
A union appends records vertically, combines rows from multiple tables, and generally requires compatible column structures. It is useful for combining monthly, quarterly, yearly, or departmental datasets that follow a common format.
2. Understanding How Union Works
Consider two tables containing sales information for different months. Both tables have the same columns: Order ID, Product, Region, and Sales. Tableau can combine these tables by placing the rows from the second table below the rows from the first.
A union combines records by appending rows from multiple tables.
3. Example: Combining Monthly Sales Data
Suppose a company maintains separate Excel sheets for January and February sales. Each sheet contains the same columns and stores sales transactions for a different month.
January Sales Table
| Order ID | Product | Region | Sales |
|---|---|---|---|
| 101 | Laptop | West | 50000 |
| 102 | Mobile | North | 25000 |
| 103 | Tablet | South | 30000 |
February Sales Table
| Order ID | Product | Region | Sales |
|---|---|---|---|
| 104 | Laptop | East | 60000 |
| 105 | Mobile | West | 20000 |
| 106 | Monitor | North | 15000 |
Union Result
After performing a union, Tableau appends all February records below the January records. The resulting table contains six rows and the same four columns.
| Order ID | Product | Region | Sales |
|---|---|---|---|
| 101 | Laptop | West | 50000 |
| 102 | Mobile | North | 25000 |
| 103 | Tablet | South | 30000 |
| 104 | Laptop | East | 60000 |
| 105 | Mobile | West | 20000 |
| 106 | Monitor | North | 15000 |
Total records after union: 6
4. Requirements for Creating a Union
Before creating a union, it is important to understand the structure of the tables. Tables should contain similar types of information so their records can be combined meaningfully.
Compatible Column Structures
Ideally, the tables should contain the same column names and compatible data types. When column names differ, Tableau can align fields using its union field-matching behavior, but unmatched fields may result in null values.
| January Table | February Table | Compatibility |
|---|---|---|
| Order ID | Order ID | Matching field |
| Product | Product | Matching field |
| Region | Region | Matching field |
| Sales | Sales | Matching field |
5. Types of Union in Tableau
Tableau supports manual unions and wildcard unions. Manual unions allow you to select individual tables, while wildcard unions help combine multiple matching tables automatically.
5.1 Manual Union
A manual union is created by dragging individual tables into the union area in Tableau's physical layer. You explicitly select which tables should be combined.
Manual unions allow you to select specific tables for combining.
When to Use Manual Union
Use manual unions when you have a small number of tables and want precise control over which tables are included. For example, you can manually combine January, February, and March sales tables.
5.2 Wildcard Union
A wildcard union automatically combines tables whose names match a specified pattern. It is useful when multiple files or tables follow a consistent naming convention.
For example, if monthly sales tables are named Sales_January, Sales_February, and Sales_March, you can use a wildcard pattern to include matching tables.
Example Wildcard Pattern
Sales_*
Sales_January
Sales_February
Sales_March
Sales_April
The wildcard pattern identifies tables that match the specified naming convention. Newly available matching tables can also be included when the union is refreshed, subject to the data source and connection behavior.
Wildcard unions identify and combine tables matching a naming pattern.
6. How to Create a Manual Union in Tableau
Follow these steps to create a manual union using Tableau Desktop.
- Open Tableau Desktop.
- Connect to an Excel file or supported data source.
- Open the Data Source page.
- Drag the first table onto the logical canvas.
- Double-click the logical table to open its physical layer.
- Drag the second table into the physical canvas.
- Drag the second table below the first table until the union option appears.
- Drop the table into the union area.
- Drag additional tables into the union if required.
- Review the union preview to verify the combined records.
Follow the steps to create and validate a manual union.
7. How to Create a Wildcard Union in Tableau
Wildcard unions help combine multiple tables automatically based on a common naming pattern. This is especially helpful when working with many similarly named tables.
- Connect to a supported data source.
- Open the Data Source page.
- Drag a table into the physical layer.
- Double-click the table to open the physical layer if required.
- Open the union options.
- Select the wildcard union option.
- Choose the appropriate matching criteria.
- Enter the table naming pattern.
- Review the tables identified by the pattern.
- Confirm the union and inspect the resulting data.
Wildcard Union Configuration Example
Table Name Pattern:
Sales_*
Matching Tables:
Sales_January
Sales_February
Sales_March
Sales_April
Result:
One Combined Sales Table
The exact wildcard configuration options depend on the connector and data source. Always check the matching-table preview before confirming the union.
8. Union vs Join vs Relationship
Tableau provides multiple ways to combine data. Understanding their differences helps you select the correct technique for your reporting requirements.
Union adds rows, joins combine columns, and relationships connect logical tables.
| Feature | Union | Join | Relationship |
|---|---|---|---|
| Combination direction | Vertical | Horizontal | Logical connection |
| Main purpose | Append rows | Combine columns | Connect related logical tables |
| Matching fields | Not required for appending rows | Required for join conditions | Required to define relationships |
| Table behavior | One combined physical table | One combined physical table | Separate logical tables |
| Example | Monthly sales tables | Customers and orders | Customers and transactions |
9. Understanding Null Values in Unions
When tables have different column structures, Tableau may create additional fields to accommodate the available columns. Records from tables that do not contain a particular field can display null values in that field.
Example: Different Column Names
| January Table | February Table |
|---|---|
| Order ID | Order ID |
| Product | Product Name |
| Sales | Revenue |
If Tableau treats differently named fields as separate columns, the resulting union can contain null values in the columns that are absent from a particular table. Review the union preview and field mapping to ensure that the intended information is aligned correctly.
10. Common Union Errors and Solutions
| Problem | Possible Cause | Solution |
|---|---|---|
| Null values in columns | Some tables do not contain matching fields. | Check column names and field mapping. |
| Incorrect data types | Fields use incompatible data types. | Standardize data types before combining. |
| Missing records | A table was not included in the union. | Review the union configuration. |
| Unexpected duplicate records | Source tables contain repeated records. | Inspect the original tables and remove duplicates when appropriate. |
| Wildcard does not include a table | The table name does not match the pattern. | Check the naming convention and wildcard criteria. |
11. Best Practices for Unioning Data
Before creating a union, verify that the tables represent compatible business information. Use consistent column names and data types wherever possible. Review the resulting data preview, check for null values, and validate record counts against the original tables. For recurring monthly or departmental datasets, use a consistent naming convention so wildcard unions can identify the intended tables.
Summary
Unioning Data in Tableau is used to combine multiple tables by appending their rows vertically. It is particularly useful when combining monthly, quarterly, yearly, or departmental datasets that contain similar information. Tableau supports manual unions for selecting specific tables and wildcard unions for identifying tables through naming patterns. Unlike joins, unions do not combine records through matching key fields. Understanding column compatibility, field mapping, data types, and null values helps create accurate combined datasets for analysis and reporting.