In this article
1: Summary
Use the tabletransform to add or update variables in an existing table. This transform is ideal for enriching datasets with calculated fields or recoded values. You can also use it to apply conditional updates based on filter logic.
You can modify a tableeither by referencing its name directly or by using the table property.
2: Modifying an Existing Table
There are two ways to specify the target table:
2.1: Method A: Use the Entity Name
table #response {
// Actions go here
}The name of the entity (e.g., #response) must match an existing table in the dataset.
2.2: Method B: Use the table Property
table {
table: .table:
// Actions go here
}If both a name and a table property are used, the table property takes precedence.
3: Creating New Variables
Use the action create block to define one or more new variables:
action create {
variable opentext #PH10039_orig {
value: :PH10039
}
}3.1: Supported Variable Types
singleChoicetext / openTextbooleannumeric / openNumericnumericlistauto(copies schema from an existing variable)
Each variable must be given a unique ID (e.g., #PH10039_orig), and you can define properties such as value, label, and required.
4: Updating Existing Variables
Use action update to conditionally modify values in an existing variable:
action update {
value: .responses:wave <= 1
}
set: :ev1039
value: recode(.response:EV1039, @mappingWave1)
}4.1: Key Properties
filter expression: Filters rows before update logic is applied. Must evaluate totrue.set: The target variable to update.value: The new value to assign.
Multiple action update blocks can be used and are evaluated in the order they appear.
5: Example
table #response {
action create {
variable opentext #PH10039_orig {
value: :PH10039
}
} action update {
filter expression {
value: .responses:wave <= 1
}
set: :ev1039
value: recode(.response:EV1039, @mappingWave1)
} This example adds a new text variable and updates an existing one only for rows where wave <= 1.
5.1: Best Practices
Always provide clear labels and default values for variables where applicable.
Use filter expression blocks to prevent unintended updates.
Use autovariable type to copy from existing schema when working with repeatable fields.