What is a Union in Tableau?

Cody Schneider8 min read

A Tableau union lets you stack multiple datasets on top of each other, but it only works if your data tables share the same structure. This tutorial will walk you through exactly what a union is, when you should use one, and how to create them in Tableau step-by-step.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

What Exactly is a Union in Tableau?

In the simplest terms, creating a union means appending rows from one table to another. Imagine you have two separate lists of customer orders - one for January and one for February. A union takes the February list and sticks it onto the end of the January list, creating a single, longer list with all the orders from both months. It's like stacking two identical LEGO bricks on top of each other to make a taller tower.

The key here is that the datasets you want to combine must have a similar structure. This means they should have the same columns, in roughly the same order, and with the same data types. For example, if your January sales sheet has columns for Order ID, Product, Customer Name, and Sale Amount, your February sheet should have the exact same columns.

Union vs. Join: Stacking vs. Stitching

It’s easy to get unions and joins confused, but they serve very different purposes.

  • A union adds rows to your dataset, making it longer (taller). You use it when you have multiple tables with the same kind of data (e.g., monthly sales reports).
  • A join adds columns to your dataset, making it wider. You use it when you have different tables with related information that you want to link together (e.g., joining a sales table with a customer information table using a common Customer ID field).

Think of it this way: unions stack, and joins stitch. One makes your data taller, the other makes it wider.

When Should You Use a Union?

Unions are incredibly useful when your data is split into multiple files or tables based on time, region, or some other category, but otherwise shares an identical layout. Here are the most common scenarios where you’ll reach for a union.

1. Combining Data Over Time

This is the most frequent use case. Businesses often generate reports as separate files for each day, week, month, quarter, or year.

  • Monthly Sales Files: You have January_Sales.csv, February_Sales.csv, March_Sales.csv, and so on. A union allows you to combine all 12 files into a single master sales table to analyze performance for the entire year.
  • Weekly Web Traffic Exports: Maybe you export Google Analytics data every week. A union lets you consolidate these weekly files to track trends over several months.
GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

2. Consolidating Data from Different Categories

Sometimes, data is segmented by categories like sales regions, product lines, or store locations, with each segment stored in its own file or spreadsheet tab.

  • Regional Performance: Your company has separate reports for its North, South, East, and West sales regions. Unioning these files gives you a complete, company-wide view of sales performance.
  • Multi-Store Retail Data: A retail chain might have a separate transaction log for each store location. By unioning these logs, a manager can analyze total sales and compare store-by-store performance.

3. Merging Tables Within a Single Database

Even if your data isn't in separate files, you might have tables within a single database that need to be stacked. For instance, a database might have an Orders_2023 table and an Orders_2024 table. You can use a union to combine them for a multi-year analysis.

How to Create a Union in Tableau: A Step-by-Step Guide

Creating a union in Tableau's Data Source pane is thankfully straightforward. There are two primary methods: the manual "drag-and-drop" method for a few tables and the "wildcard" method for automatically combining many files at once.

Method 1: The Manual Drag-and-Drop Union

This method is perfect when you only need to combine a handful of tables or sheets from an Excel workbook.

Step 1: Connect to Your Data Open Tableau and in the "Connect" pane, select the type of file or database you're using. For this example, let's assume we're using a single Excel file named Quarterly_Sales.xlsx that has four separate sheets: Q1_Sales, Q2_Sales, Q3_Sales, and Q4_Sales.

Step 2: Drag Your First Table to the Canvas After connecting, you'll see a list of available sheets or tables in the left sidebar. Drag the first one, Q1_Sales, onto the canvas area that says "Drag tables here."

Step 3: Add More Tables to Create the Union Now, drag your second table, Q2_Sales, from the sidebar. Don't drop it next to the first one — drag it directly underneath Q1_Sales. As you hover, an orange box with the words "Drag table to union" will appear. Release the mouse button. You’ve just created a union! Tableau appends the rows from Q2_Sales to Q1_Sales. You can repeat this process for Q3_Sales and Q4_Sales to combine all four quarters into one dataset. When you're done, the data grid below will show data from all four sheets stacked together.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Method 2: The Automatic Wildcard Union

What if you have dozens or even hundreds of files, like daily log files for an entire year? Dragging and dropping each one would be a nightmare. This is where the wildcard union comes in handy.

A wildcard union lets you tell Tableau to automatically find and union all files in a specific folder that match a certain naming pattern.

Let's say you have a folder containing monthly sales CSV files named:

  • Sales-Data-Jan-2024.csv
  • Sales-Data-Feb-2024.csv
  • Sales-Data-Mar-2024.csv
  • ...and so on.

Step 1: Connect and Drag Connect to the data source (in this case, "Text File") and select just one of the files, like Sales-Data-Jan-2024.csv. Instead of dragging the file itself to the canvas, drag the "New Union" option from the left sidebar.

Step 2: Configure the Wildcard Union A dialog box will appear. Here you can configure the wildcard search.

  • Make sure you're in the correct folder.
  • In the "Search In" settings, you can tell Tableau to look in subfolders as well.
  • In the text box, you'll define the matching pattern using an asterisk (*) as a placeholder. For our example, we want to include all files that start with Sales-Data- and end with -2024.csv. Our wildcard pattern would be: Sales-Data-*-2024.csv.

Click "OK," and Tableau will automatically find all matching files and union them together. This is a huge time-saver for anyone who works with regularly generated, consistently named files.

Working with Unioned Data: The Path and Table Name Fields

After you create a union, Tableau adds two new columns to your dataset to help you keep track of where the data came from:

  • Table Name: This field contains the name of the original table or sheet that each row came from (e.g., "Q1_Sales," "Q2_Sales").
  • Path: This field shows the full file path and name for data coming from files.

These fields are incredibly useful for analysis! You can drag Table Name onto a chart to compare performance across different quarters, or use it as a filter to isolate data from a specific month or region.

Troubleshooting Common Union Issues

Even with a good process, you might run into a few common pitfalls. Here’s how to handle them.

1. Mismatched Column Names

What if one file has a column named Sale_Amount and another has it named Revenue? When you union them, Tableau will see them as two different columns and create both, leading to lots of null values. One column will have data where the other has nulls, and vice versa.

The Fix: In the Data Source pane’s data grid, you can merge mismatched fields. Simply select both columns (hold Ctrl or Cmd and click each column header), right-click, and choose "Merge Mismatched Fields." Tableau will combine them into a single column.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

2. Inconsistent Data Types

Sometimes, a column like Order_ID might be a number in one file but formatted as text (a string) in another. This can cause errors or unexpected results. Tableau is usually smart about this, but you might need to intervene.

The Fix: You can manually change the data type of a column by clicking the data type icon at the top of the header (e.g., # for numbers, Abc for text) and selecting the correct type. Make sure the data types are consistent for all fields you want to combine across all your tables before or after the union.

3. Data Duplication Caution

A union simply appends rows, it doesn't check for duplicates. If you accidentally include a file twice, or if your source files have overlapping date ranges (e.g., one report is from Jan 1-31 and another is from Jan 25-Feb 20), those overlapping rows will be duplicated in your final dataset. This isn't a Tableau error, but a data hygiene issue to be aware of during your preparation process.

Final Thoughts

A union in Tableau is a simple but essential tool for combining similarly structured data into a single, comprehensive dataset. Whether you're stacking monthly reports or regional sales figures, mastering unions will allow you to perform deeper analysis across time and categories without messy VLOOKUPs in spreadsheets.

While tools like Tableau offer powerful features, we know the setup process - connecting sources, cleaning data, and configuring unions and joins - can be tedious and time-consuming. We built Graphed to remove that friction. By connecting all your sales and marketing platforms in one click, you can ask a question in plain English like, "show me total sales from Shopify and traffic from Google Analytics by month on a line chart" and instantly get a real-time dashboard, letting you skip the manual data prep entirely.

Related Articles

How to Enable Data Analysis in Excel

Enable Excel's hidden data analysis tools with our step-by-step guide. Uncover trends, make forecasts, and turn raw numbers into actionable insights today!