TABLEAU • CONNECTING TO DATA

Unions — Create unions (append rows) and validate schema alignment

Combine multiple tables by stacking rows while ensuring structural consistency across heterogeneous data sources.

Historical Context & Motivation

Data rarely arrives in a single, monolithic table. Organizations routinely partition records across multiple files—monthly sales logs, regional inventory snapshots, quarterly survey exports—each sharing an identical or nearly identical schema. The need to vertically concatenate these fragments into a unified dataset predates visual analytics tools by decades, rooted in the relational algebra concept of the UNION operator introduced by E. F. Codd in his foundational 1970 paper on the relational model. Tableau adopted this operator as a first-class data-connection feature to let analysts combine structurally similar tables without writing SQL, but understanding the underlying semantics—especially schema alignment—remains essential for avoiding silent data-quality issues.

1970
Codd's Relational Model
E. F. Codd publishes "A Relational Model of Data for Large Shared Data Banks," formalizing UNION as one of the fundamental relational algebra operators that combine two union-compatible relations by appending their tuples.
1986
SQL Standard Adopted
ANSI adopts the first SQL standard (SQL-86), codifying UNION and UNION ALL as keywords. The distinction between duplicate-eliminating UNION and duplicate-preserving UNION ALL becomes a cornerstone of query design.
2003
Tableau 1.0 Released
Tableau's earliest versions focus on drag-and-drop visualization from single tables. Combining multiple data sources requires manual preprocessing in databases or spreadsheet tools.
2016
Union Support in Tableau 10.0
Tableau 10.0 introduces native union capabilities in the Data Source pane, allowing users to drag tables onto each other to append rows. Wildcard unions enable pattern-based file matching across directories.
2020+
Relationships & Prep Enhancements
Tableau Prep Builder adds visual union steps with automatic field-name matching, mismatched-field indicators, and data-type coercion warnings—making schema validation an interactive, exploratory workflow.

The central question this lesson addresses is straightforward yet deceptively nuanced: when you stack rows from two or more tables, how do you guarantee that the resulting dataset is structurally coherent? Mismatched column names, differing data types, and missing fields can produce a union that looks complete but silently corrupts downstream analysis. Mastering union creation and schema validation is therefore a prerequisite for reliable data pipelines in Tableau.

Core Principles & Definitions

Before creating unions in Tableau, it is important to internalize several foundational concepts that govern how row-appending operations behave. Unlike a join, which combines columns from different tables based on a key, a union combines rows from tables that share a compatible structure. The following principles capture the essential mechanics and potential pitfalls.

1

Union = Append Rows

A union vertically concatenates two or more tables. If Table A has m rows and Table B has n rows, the unioned result has m + n rows (assuming UNION ALL semantics, which Tableau uses by default).
2

Schema Alignment

For a valid union, columns must be matched by name (or alias) and compatible data type. Tableau performs automatic name-based matching and adds mismatched fields as separate columns filled with NULLs.
3

Union-Compatibility

Two relations are union-compatible when they have the same degree (number of columns) and each pair of corresponding attributes shares a compatible domain. Tableau relaxes this by allowing mismatches but flags them visually.
4

Generated Fields

Tableau appends metadata fields—Sheet (source file/sheet name) and Table Name—to every unioned row, enabling analysts to trace each record back to its origin table for auditing and filtering.
5

Wildcard Unions

Wildcard unions use pattern matching (e.g., sales_*.csv) to automatically include all files in a directory that match a naming convention, streamlining unions across dozens or hundreds of files.
KEY TAKEAWAY
Think of a union like appending pages to a spreadsheet: if every page has the same column headers in the same order, stacking is trivial. But if one page renames "Revenue" to "Sales" or stores dates as strings instead of date objects, you get a messy stack of misaligned data. Schema validation is the process of checking those headers before you staple the pages together.

Visual Explanation — Union vs. Join

The most common source of confusion for newcomers is the distinction between unions and joins. The diagram below illustrates how a union appends rows vertically while a join extends columns horizontally. Each operation serves a fundamentally different data-integration purpose, and selecting the wrong one can produce a Cartesian explosion or a table riddled with NULLs.

Left: a union stacks Table A (2 rows) on top of Table B (2 rows), producing 4 rows with the same 3 columns. Appended rows from Table B are shown in cyan. Right: a join on ID merges columns from Table A and Table C side by side, keeping the row count at 2 but expanding to 3 columns.

As the diagram makes clear, choosing between a union and a join depends on the structural relationship between your tables. If two tables describe the same entity with the same attributes but different records (e.g., January sales and February sales), a union is appropriate. If they describe different attributes of the same entities (e.g., customer demographics and customer orders linked by a customer ID), a join is the correct operation. Conflating the two produces either an inflated row count or a sparse, NULL-riddled table.

How Unions Work — The Schema Alignment Process

When Tableau executes a union, it performs several internal operations that mirror classical relational algebra. Understanding these mechanics allows you to anticipate and debug the mismatches that commonly arise. The process can be decomposed into three phases: field enumeration, name-based matching, and type coercion.

Phase 1 — Field Enumeration

Tableau scans every table in the union and builds a master column list. Formally, if table Ti has column set Ci, the output schema S is the union of all column sets: S = C1 ∪ C2 ∪ … ∪ Ck. Any column that exists in one table but not another will appear in the result, with NULL values populating the missing cells.

OUTPUT SCHEMA
S = C₁ ∪ C₂ ∪ … ∪ Cₖ
where S is the result schema, Ci is the column set of table i, and k is the number of tables in the union. The vertical bar count of the result is |S| = |C₁ ∪ C₂ ∪ … ∪ Cₖ|.

Phase 2 — Name-Based Matching

Tableau matches columns across tables using case-insensitive name comparison. If Table A has a column named "Revenue" and Table B has "revenue," Tableau treats them as the same field. However, if Table B instead names it "Sales," Tableau creates two separate columns in the result—"Revenue" (NULL for Table B rows) and "Sales" (NULL for Table A rows). This is where manual field merging becomes necessary: in the Data Source pane, you can right-click mismatched columns and select "Merge Mismatched Fields" to unify them under a single header.

Phase 3 — Type Coercion

When matched columns have differing data types—for instance, one table stores "Price" as an integer and another as a float—Tableau applies implicit type promotion following a widening hierarchy: Boolean → Integer → Float → String. A more serious mismatch, such as a Date column in one table and a String in another, results in the broader type (String) being selected. This can silently degrade analytical functionality—string dates, for example, cannot be used with Tableau's date functions without explicit type conversion. Schema validation should therefore always include checking the resulting data types in the Data Source pane's metadata grid after performing a union.

ROW COUNT IDENTITY
|R| = |T₁| + |T₂| + … + |Tₖ|
The total row count |R| of a UNION ALL result equals the sum of row counts across all k input tables. No deduplication occurs (Tableau uses UNION ALL semantics). If duplicates need to be removed, post-union filtering or LOD expressions are required.

Schema Validation — Detecting and Resolving Mismatches

Schema validation is the disciplined process of ensuring that all tables in a union share the expected structure before and after the concatenation. Tableau provides several visual cues to facilitate this process, but a systematic approach—especially in production data pipelines—requires understanding the taxonomy of mismatches and their resolution strategies.

The schema validation workflow proceeds through four stages: enumerating fields from each source table, identifying name and type mismatches, resolving them via merging or type correction, and producing a validated union result. Red NULL values indicate fields that exist only in a subset of source tables. The Source column (generated by Tableau as "Table Name") enables provenance tracking.
Common schema mismatches and their resolution strategies in Tableau Desktop and Tableau Prep.
Mismatch TypeExampleResolution in Tableau
Column NameAmt vs. AmountRight-click → Merge Mismatched Fields, or rename in Tableau Prep
Data TypeInteger in T1, String in T2Tableau promotes to broader type (String). Fix by changing type in metadata grid or preprocessing.
Missing Column"Region" exists only in T3Column appears in result; rows from other tables receive NULL. Use IFNULL() or ZN() for defaults.
Column OrderColumns in different positions across tablesTableau matches by name, not position. Column order differences are handled automatically.
Case VariationRevenue vs. revenueMatched automatically (case-insensitive comparison). No action needed.

Worked Example — Unioning Monthly Sales Files

Suppose you are a data analyst at a retail company. The sales team exports monthly transaction data as separate CSV files: sales_jan.csv, sales_feb.csv, and sales_mar.csv. Each file should contain columns for OrderID, Product, Quantity, UnitPrice, and OrderDate. However, an upstream schema change in March renamed "UnitPrice" to "Price" and added a "Channel" column. Your task: union all three files and validate the schema.

Creating and Validating a Multi-File Union in Tableau Desktop
1
Step 1 — Connect to the First FileOpen Tableau Desktop and select "Text file" as the connector. Navigate to the directory containing your CSV files and open sales_jan.csv. Tableau displays the file in the Data Source pane with its five columns: OrderID, Product, Quantity, UnitPrice, OrderDate.
Initial table displayed with 5 columns and January data rows.
2
Step 2 — Create the Union via Drag-and-DropIn the left panel, locate sales_feb.csv and sales_mar.csv. Drag sales_feb.csv directly onto the existing table in the canvas until the "Drag table to union" prompt appears; drop it. Repeat with sales_mar.csv. Alternatively, click "New Union" in the left panel and add all three files. Tableau creates a union icon in the canvas.
Union created with 3 tables. The data preview now shows combined rows from all three files.
3
Step 3 — Inspect the Metadata Grid for MismatchesSwitch to the metadata view (grid icon at the top of the Data Source pane). You will observe 7 columns instead of the expected 6 (5 original + Table Name). The mismatch: "UnitPrice" appears with NULLs for March rows, and "Price" appears with NULLs for January and February rows. Additionally, the "Channel" column is present only for March rows. The "Table Name" field shows the source file for each row.
Identified 2 schema issues: UnitPrice/Price name mismatch, and Channel as a March-only field.
4
Step 4 — Merge Mismatched FieldsSelect both "UnitPrice" and "Price" columns in the metadata grid (Ctrl+click), then right-click and choose "Merge Mismatched Fields." Tableau consolidates them into a single column named "UnitPrice" (the first-encountered name is retained). Verify in the data preview that all rows now have a non-NULL value in this column.
UnitPrice and Price merged into a single "UnitPrice" column with no NULLs.
5
Step 5 — Validate Data Types and Handle Extra ColumnsConfirm that OrderDate is recognized as a Date type (not String) for all rows by checking the type icon in the metadata grid. For the "Channel" column—which has NULL values for January and February rows—decide whether to keep it (useful for channel-based analysis in March onward) or create a calculated field using IFNULL([Channel], 'Unknown') to assign a default. Finally, verify the total row count equals the sum of rows across all three source files.
Validated union: 6 columns (OrderID, Product, Quantity, UnitPrice, OrderDate, Channel), correct data types, row count = |Jan| + |Feb| + |Mar|.
💡 Wildcard Union Alternative
For scenarios with many identically named files (e.g., sales_*.csv), use a wildcard union. In the New Union dialog, switch to the "Wildcard (automatic)" tab and specify the matching pattern and directory. Tableau will automatically union all matching files, including any added in the future—ideal for automated data refresh workflows.

Unions Compared — Join, Blend, and Relationship Alternatives

Tableau offers four primary mechanisms for combining data: unions, joins, blends, and relationships. Selecting the correct mechanism depends on the structural relationship between your data sources and the granularity requirements of your analysis. The table below provides a systematic comparison across key dimensions to guide this decision.

Comparative analysis of Tableau data combination methods.
DimensionUnionJoinBlend
DirectionVertical (adds rows)Horizontal (adds columns)Virtual horizontal link
Schema RequirementSame or compatible columnsShared key column(s)Linking field defined per sheet
Data SourcesSame connection onlySame connection onlyCross-connection (e.g., SQL + Excel)
Row Count ImpactSum of all table row countsVaries by join type (inner, left, etc.)Primary source determines row count
Duplicate HandlingUNION ALL — retains duplicatesCan multiply rows (fan-out)Aggregates secondary source
Best Use CaseCombining partitioned files (monthly logs, regional exports)Enriching records with attributes from related tablesCombining data from different database systems
🔀 WHEN TO USE EACH METHOD
Think of data combination methods as construction techniques: a union is like adding more floors to a building (same blueprint, more stories), a join is like adding a wing (extending the footprint), and a blend is like running a skybridge between two separate buildings (connecting independent structures at specific points). Each requires different structural compatibility checks.

Connection to Advanced Data Engineering

Tableau's union feature provides an accessible entry point into concepts that scale up significantly in production data engineering. Understanding where Tableau unions sit on the continuum from ad-hoc analysis to enterprise ETL pipelines will help you recognize when to graduate beyond the desktop tool.

Tableau unions vs. production-grade data engineering approaches.
FeatureTableau Desktop UnionProduction ETL / Data Engineering
Schema EvolutionManual merge of mismatched fields; no versioningSchema registries (e.g., Apache Avro, Confluent Schema Registry) with backward/forward compatibility rules
DeduplicationNot built in (UNION ALL); requires post-hoc filteringSQL UNION (with dedup), or tools like dbt with unique key tests
Data Quality TestingVisual inspection in metadata gridAutomated assertions (Great Expectations, dbt tests) checking schema, nulls, ranges, uniqueness
ScaleTens to hundreds of files; in-memory processingMillions of partitions; distributed engines (Spark, BigQuery) with lazy evaluation
AutomationWildcard unions with scheduled extract refreshOrchestration frameworks (Airflow, Prefect) with dependency graphs and retry logic

For Computer Science students, the concepts introduced here—union compatibility, type coercion hierarchies, and schema validation—map directly onto topics in database theory (relational algebra), type theory (type lattices and widening), and software engineering (contract-based design). Tableau Prep's union step, for instance, is functionally equivalent to a pandas pd.concat() call with axis=0 and join='outer', where column alignment follows the same outer-union logic described in this lesson. Recognizing these parallels strengthens both your Tableau proficiency and your data engineering fundamentals.

Practice Problems

PROBLEM 1CONCEPTUAL
Explain the fundamental difference between a union and a join in Tableau. In what scenario would using a join instead of a union produce incorrect or misleading results?
PROBLEM 2BASIC CALCULATION
Table A has 1,200 rows and 8 columns. Table B has 850 rows and 8 columns (same column names). Table C has 1,500 rows and 9 columns (8 matching columns plus one extra column called "Status"). After performing a union of all three tables, how many rows and columns will the result contain? What values will the "Status" column hold for rows from Tables A and B?
PROBLEM 3INTERMEDIATE
You are unioning four CSV files exported from different regional offices. After creating the union, you notice that the metadata grid shows two columns: "Transaction_Date" (Date type) and "Trans_Date" (String type). The first column has NULLs for two regions, and the second has NULLs for the other two. Describe the sequence of steps you would take in Tableau Desktop to resolve this issue and ensure all date values are properly typed.
PROBLEM 4APPLIED
A data engineering team stores sensor readings as daily CSV files named sensor_YYYYMMDD.csv in a shared directory. Each file has columns: SensorID (int), Timestamp (datetime), Reading (float), and Unit (string). A new firmware update on 2024-03-01 changed the output format: "Reading" was renamed to "Value" and a new column "Calibrated" (boolean) was added. Design a Tableau data connection strategy using wildcard unions that handles both the pre- and post-update file formats. Specify what schema validation steps are needed.
PROBLEM 5CRITICAL THINKING
Tableau's union operation uses UNION ALL semantics (no deduplication). Suppose two source tables contain overlapping records—rows that are identical across all columns. Propose two different strategies for detecting and removing these duplicates after the union. For each strategy, analyze its computational complexity and discuss under what data conditions it might fail or produce incorrect results.

Lesson Summary

A union in Tableau appends rows from two or more tables that share a compatible structure, producing a result whose row count equals the sum of all source row counts (UNION ALL semantics). Unlike a join, which extends columns horizontally via a key, unions extend rows vertically. Tableau supports both manual unions (drag-and-drop in the Data Source pane) and wildcard unions (pattern-based file matching for scalable, automated ingestion).

Schema validation is the critical step that distinguishes a reliable union from a corrupted one. It involves checking for column name mismatches (resolved via Merge Mismatched Fields), data type inconsistencies (resolved via type coercion or manual type changes), and extra or missing columns (handled via NULL-aware expressions). Mastering these techniques prepares you for production-grade data engineering workflows using SQL, pandas, and orchestration tools like dbt and Airflow.

Varsity Tutors • Tableau • Unions — Create unions (append rows) and validate schema alignment