unique
Keep only the unique rows in a data extract.
This guide explains how to configure the unique instruction. To learn about another instruction, go back to the Available custom script instructions overview.
Introduction
Use the unique instruction to keep only the unique rows in a data extract.
You can limit the instruction to certain columns in a data extract. All rows which do not include unique values in at least one of the defined columns are removed.
Creating a custom script transformation using the unique instruction
To create and configure a custom script using the unique instruction, follow these steps:
-
In the Instructions step, select the unique instruction.
-
To configure the custom script instruction, fill in the following fields. Required fields are marked with an asterisk (*).
-
Keys
-
Enter the names of the columns where Adverity searches for unique rows.
Select a column in one of the following ways:
-
Select String and enter the name of the column.
-
Select Integer and enter the position of the column in the data extract as an index value. Counting starts at 0. To select the first column, enter
0
. To select the second column, enter1
. To select the last column in the data extract, enter-1
.
Leave this field empty to check all columns in the data extract.
-
-
Presorted
-
Select this checkbox if the rows in the data extract have been sorted before the transformation runs.
-
Subtable
-
Enter the name for a subtable that you want to use within this custom script.
A subtable is a temporary table that 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.
If a subtable does not exist for the current custom script, the transformation is applied to the data extract, and the enriched data is output into the subtable. If the subtable already exists for the custom script, the subtable is used as the input for the transformation and optionally as the output.
Example 1 - Keeping only the unique rows in the data extract
Transformation configuration
-
Keys
-
Leave this field empty.
-
Presorted
-
Do not select this checkbox.
Data table before transformation
Campaign |
Ad Group |
Clicks |
---|---|---|
Brand |
media |
2792 |
Brand |
media |
2792 |
Brand |
media |
6760 |
Dashboard |
ecommerce |
4032 |
Dashboard |
longevity |
4875 |
Outreach |
media|social |
6531 |
Outreach |
media|social |
8619 |
Outreach |
organic growth |
3260 |
Data table after transformation
Dimension 1 |
Dimension 2 |
Metric 3 |
---|---|---|
Brand |
media |
6760 |
Dashboard |
ecommerce |
4032 |
Dashboard |
longevity |
4875 |
Outreach |
media|social |
6531 |
Outreach |
media|social |
8619 |
Outreach |
organic growth |
3260 |
The first two rows of the data extract are the same. Therefore, they are not unique. The transformation removes the first two, non-unique rows from the data extract.
Example 2 - Keeping only the unique rows in certain columns of the data extract
Transformation configuration
-
Keys
-
Enter the following as strings in two key fields:
-
Campaign
-
Ad Group
-
-
Presorted
-
Do not select this checkbox.
Data table before transformation
Campaign |
Ad Group |
Clicks |
---|---|---|
Brand |
media |
2792 |
Brand |
media |
2792 |
Brand |
media |
6760 |
Dashboard |
ecommerce |
4032 |
Dashboard |
longevity |
4875 |
Outreach |
media|social |
6531 |
Outreach |
media|social |
8619 |
Outreach |
organic growth |
3260 |
Data table after transformation
Dimension 1 |
Dimension 2 |
Metric 3 |
---|---|---|
Dashboard |
ecommerce |
4032 |
Dashboard |
longevity |
4875 |
Outreach |
organic growth |
3260 |
The first three rows contain the same data in the defined columns. Therefore, they are not unique and the transformation removes them from the data extract. The rows that contain CCC
and GGG
are also not unique and are removed.