Step: Stack
Overview
The Stack step will add or remove rows from another table that align with the existing variable structure.
Example starting data:
Source (t0) table1 (t1)
/*---------+--------* /*---------+--------+
| student | score | | student | score |
+---------+--------+ +---------+--------+
| jane | 83 | | tom | 83 |
| kim | 35 | | sherri | 92 |
| sam | 74 | | pat | 48 |
| zay | 62 | | jade | 87 |
*---------+--------*/ *---------+--------*/Example output data:
Union rows from Table B.
/*---------+--------*
| student | score |
+---------+--------+
| jane | 83 |
| kim | 35 |
| sam | 74 |
| pat | 62 |
| tom | 83 |
| sherri | 92 |
| pat | 48 |
| jade | 87 |
*---------+--------*/Step structure

Field descriptions
Stacked table
The table containing the rows you wish to add.
Stack type
How the rows will be added.
Variable alignment
How you define the variable structure between the source and the Stacked table.
All matching variables: Will automatically match variables and only include variables with a matching name. The rest will be dropped.
All variables: Will automatically match variables and keep all variables in the output. Values will be marked null where there is no match for an existing variable
Manually match variables: Will require you to align variables between two tables.
Retype variables
Variables will be retyped in order to be aligned.
Only keep distinct rows
If any added rows are an exact duplicate of an existing row, it will be dropped from the output.
Create variable for table name (Union only)
In order to record in the data to indicate where new rows came from, you can opt to create a new variable with table information.
Stack types
The most common stack type is a Union, which can be useful when combining data which has been broken up into multiple tables with the same structure.
Union
Appends all of the stacked table’s rows to the source table.
Except
Keep only distinct rows in the source table that match rows in the stacked table.
Intersect
Keep only distinct rows that are in the source table and stacked table.
Examples
Example 1: Basic union
Let's say we have data broken into two tables with the same structure. We want to add all rows together as they are.
Starting data:
Input fields:

Stacked table: The data is in
table1, so we select that here.Stack type: We want to add all rows, so we select
Unionhere.Variable alignment: Somehow our variable names shifted between tables, so we can't automatically align tables. We choose
Manually match variables, then fill in the variable names underSource variableandStacked table variable.Where the variable names are different, the output will keep the name of the
Source variablewhen it exists.
Output data:
Example 2: Bulk union and variable misalignment
To continue the previous example, let's say we have a third table of data, and it has additional information that was not present in the first two about date. We want to keep this information and also keep track of which rows came from which table.
Starting data:
Input fields:

We create one block for the
t1union, and a second block for thet2union,Variable alignment: Since we want to keep all variables no matter if they have matches, we select
All variables.Create variable for table name: We check this box since we want to keep track of which table each row came from.
Note that
Source table nameis automatically populated with the name of this transform's source table.
Output data:
Example 3: Except
Let's say we have a table with information about students and their test scores, and we have identified some students that have dropped the course and that we no longer need in the original table. We have gathered those students in t1.
Starting data:
Input fields:

Output data:
The rows that were in both tables are now removed.
Example 4: Intersect
Let's say we have two tables full of students, one from who took our fall semester class, and one from the spring semester class. We want to only keep student rows for people who took both classes, so those who are present in both tables.
Input fields

Output data:
Only rows that were in both tables now remain.
Last updated
Was this helpful?

