mergecolumn
On this page
Combine fields from different columns into a single column.
Introduction
Use the mergecolumn instruction to combine different columns in a data extract into a single column. The combined values are stored in a JSON-style dictionary. The name of the column is stored as the dictionary key, and the value within the column is stored as the dictionary value.
Creating a custom script transformation using the mergecolumn instruction
To create and configure a custom script using the mergecolumn instruction, follow these steps:
-
In the Instruction step, select the mergecolumn instruction.
-
To configure the custom script instruction, fill in the following fields. Required fields are marked with an asterisk (*).
- Fieldname*
Enter the name of the new column that contains the merged values.
- Columns
Enter the names of the columns to combine into one column. Click
to add the names of more columns to combine. If you select this option, the All and Prefix fields are disabled.
- All
Select this option if you want to merge all the columns within a table into a single column. If you select this option, the Columns and Prefix fields are disabled.
- Prefix
Enter the start of the names of the columns to merge. For example, enter
Ad_into prefix and only the column names that start withAd_are included in the merge transformation.If you select this option, the Columns and All fields are disabled.
- Include
Enter the names of fields to be merged.
- Exclude
Enter the names of the columns to be excluded from the merge. Use this option if you have selected the All option.
- Drop
Select this option to remove the original columns from the data extract. If selected, the original columns will remain in the data extract along with the merged columns.
- Serializer
Select the format in which the merged values are stored. Currently, the only option is JSON.
Example
Transformation configuration
- Fieldname*
Ad Group Clicks- Columns
Ad_GroupsAd_Clicks
- Drop
Select this checkbox.
- Serializer
JSON
Data table before transformation
Scroll horizontally to see the full table.
Campaign | Ad_Group | Ad_Clicks |
|---|---|---|
Brand | media | 7 |
Brand | ecommerce | 3 |
Dashboard | media|social | 18 |
Data table after transformation
Scroll horizontally to see the full table.
Campaign | Ad Group Clicks |
|---|---|
Brand | {“Ad Group”:”media”, “Clicks”:”7”} |
Brand | {“Ad Group”:”ecommerce”, “Clicks”:”3”} |
Dashboard | {“Ad Group”:”media|social”, “Clicks”:”18”} |