Union Tool: Vertical Table Stacking & Schema Alignment Strategies
Overview & Learning Objectives
While the Join tool combines tables horizontally by appending columns side-by-side, the Union tool combines tables vertically by stacking rows on top of each other (equivalent to SQL `UNION ALL`). The Alteryx Union tool accepts unlimited incoming streams and offers three schema-matching strategies: Auto Config by Name, Auto Config by Position, and Manually Configure Fields.
- Stack multiple data streams vertically into a single unified dataset.
- Configure schema alignment: Auto Config by Name, Auto Config by Position, and Manual Alignment.
- Resolve schema mismatch warnings and manage incoming column order priority.
Industry Standard
Standard: Analytics engineering protocols at Deloitte mandate using "Auto Config by Name" with the option "Warn on Mismatched Fields" enabled to instantly alert engineers if upstream pipeline updates introduce misspelled column names.
Real-World Example: FreshBites Cafe Multi-Branch Sales Consolidation
FreshBites Cafe consolidates daily sales tables from 3 city branches into one consolidated executive sales dataset.
| Branch Stream | Incoming Headers | Union Strategy | Unified Output Table |
|---|---|---|---|
| Stream 1 (Mumbai) | `store_id`, `sales_amount`, `date` | Auto Config by Name | Aligned under `store_id`, `sales_amount`, `date` |
| Stream 2 (Delhi) | `date`, `store_id`, `sales_amount` (Reordered) | Auto Config by Name | Automatically mapped to matching column names! |
| Stream 3 (Bengaluru) | `outlet_id`, `sales_amount`, `date` (Alias gap) | Manually Configure Fields | Manually mapped `outlet_id` to `store_id` |
Configuration & Core Workflow
-- Union Tool Configuration Modes
1. Auto Config by Name (Recommended):
Matches columns with identical names regardless of column position.
2. Auto Config by Position:
Matches columns strictly by ordinal position (Column 1 to Column 1).
3. Manually Configure Fields:
Provides drag-and-drop column alignment grid to map mismatched names.
When Fields Differ:
Output Option: "Output subset of fields" OR "Output all fields (fills missing with NULL)"
Parameters Breakdown
Auto Config by Name: Aligns columns matching identical field names; reordered columns match seamlessly.Auto Config by Position: Stacks columns based strictly on order (use only when files have no headers but identical structures).Manually Configure Fields: Allows dragging columns into manual alignment slots when field names differ across sources.When Fields Differ: Controls error reporting: Error, Warn, or Ignore when stream schemas do not match.
Sample Walkthrough (Q&A)
Question: What happens in "Auto Config by Name" if Stream A has a column named `Revenue` and Stream B has `Sales`?
Formula / Action: Stream A (Revenue) UNION Stream B (Sales) by Name
Result: The output table will have BOTH columns (`Revenue` and `Sales`) with NULLs in alternating rows!
Explanation: Because names differ, Alteryx assumes they are distinct attributes. To fix this, place a Select tool upstream to rename `Sales` to `Revenue`, or use "Manually Configure Fields".
Common Mistakes & Limitations
- Using "Auto Config by Position" on tables where column orders differ, silently corrupting data by stacking customer names under phone numbers.
- Ignoring "Mismatched Fields" warnings, resulting in fragmented output tables with 50+ unintended duplicate columns.
Keyboard Shortcuts
| Action | Windows | Mac |
|---|---|---|
| Connect Multiple Streams | Drag output arrows of 5 tools into 1 Union | Drag to Union |
| Set Stream Order | Configuration -> Click "Set a Specific Output Order" | Set Output Order |
Pro Tips & Modern Alternatives
- Use a `Batch Macro` when appending 100+ files from a directory to avoid cluttering the canvas with 100 manual connections.
- Use the `Join Multiple` tool if tables share keys and need to be joined horizontally rather than stacked vertically.