distinct#
Find the number of distinct rows in a data extract.
Note
This guide explains how to configure the distinct instruction. To learn about another instruction, go back to the Custom scripts available in Adverity overview.
Introduction#
Use the distinct instruction to find the distinct rows in a data extract, and to return how many times the rows appear in the data extract.
To find only duplicate values, use the duplicates transformation.
To find distinct rows and aggregate the metric values, use the aggregate transformation.
Creating a custom script transformation using the distinct instruction#
To create and configure a custom script using the distinct instruction, follow these steps:
In the Instructions step, select the distinct instruction.
To configure the custom script instruction, fill in the following fields. Required fields are marked with an asterisk (*).
- Key
Enter the names of the columns to be used when checking for distinct rows. Click to add columns.
- Count
Enter the name of the column that is to be added to the data extract. This column displays the number of distinct rows for each unique combination of values found in the columns specified in Keys.
- Presorted
Select this checkbox if the included data extracts are presorted.
- 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#
Transformation configuration#
- Key*
Ad Group
Region
- Count
Entry Count
Data table before transformation#
Ad Group |
Region |
Clicks |
---|---|---|
media |
UK |
3493 |
media |
UK |
8891 |
media |
UK |
2782 |
ecommerce |
France |
7397 |
ecommerce |
Germany |
6397 |
social |
USA |
5645 |
social |
USA |
1946 |
social |
Spain |
3356 |
Data table after transformation#
Ad Group |
Region |
Clicks |
Entry Count |
---|---|---|---|
media |
UK |
3493 |
3 |
ecommerce |
France |
7397 |
1 |
ecommerce |
Germany |
6397 |
1 |
social |
USA |
5645 |
2 |
social |
Spain |
3356 |
1 |