recast
Use duplicated values from a data extract to create a new header.
Introduction
Use the recast enrichment instruction to transpose distinct values in a column into a header. This enrichment is the opposite of the melt enrichment instruction.
When configuring this enrichment, select the name of the column that contains the distinct values to convert into a header. See the example below.
This enrichment is often used to reverse the effects of themelt enrichment instruction.
Creating the enrichment
For more information on creating an enrichment, see Using custom scripts.
Configuring the enrichment
To configure the enrichment, fill in the following fields. Required fields are marked with an asterisk (*).
-
Key*
-
Enter the name of the column that you do not want to be transposed into the header. To keep multiple columns as columns, click
and enter the names of the columns you do not want to be transposed into the header.
-
Variablefield*
-
Enter the name of the column that contains the distinct values to transpose into the header.
-
Valuefield*
-
Enter the name of the column that contains the values used to populate the new columns. See the example below. If multiple values exist under a given key and variablefield, the enrichment combines the multiples values into a list. You can configure how the list is formatting by entering a python expression in the Reducers field.
-
Samplesize
-
Enter the number of lines to search through to find the distinct values to use in the header.
-
Reducers
-
Enter a python expression used to format multiple values into a list.
-
Missing
-
Enter a string value to use if values cannot be transposed with the given variablefield or valuefield.
-
Subtable
-
Enter the name for a subtable that you want to contain the enriched data. The enrichment is applied to the whole data extract, then the enriched data is output into the subtable you have named here.
This subtable is a temporary table, which means it only exists for this custom script. You can apply additional instructions within the same custom script to the subtable. However, the subtable cannot be used in any other custom scripts.
Example
Enrichment configuration
-
Key*
-
Campaign
-
Variablefield*
-
Transposed columns
-
Valuefield*
-
Transposed values
Data table before enrichment
Campaign |
Transposed columns |
Transposed values |
---|---|---|
Brand |
Ad Group |
media |
Brand |
Clicks |
7 |
Brand |
Ad Group |
ecommerce |
Brand |
Clicks |
3 |
Dashboard |
Ad Group |
media|social |
Dashboard |
Clicks |
18 |
Data table after enrichment
Campaign |
Ad Group |
Clicks |
---|---|---|
Brand |
media |
7 |
Brand |
ecommerce |
3 |
Dashboard |
media|social |
18 |