General: DistinctByKey
Create a flag field, set to true for the first occurrence of each unique value of a key field, for the set of records linked to each key in a primary table.
Purpose
Use this function to:
- Flag records grouped by their relationship to data in another table
Return Value
| Property | Value |
|---|---|
| FieldType | Integer |
| FieldSize | Low |
| DataType | Discrete |
| DataSize | Byte |
Example Return Value: 0 , 1, nullParameters
| Parameter | JSON | Description |
|---|---|---|
| Table | “targetTable”: “MyTableName” | The target table on which the new field will be created |
| Filter | “dataset”: {DataSet_JSON} | Optional. If a filter is applied, records not in the filter recordset will be returned as null. |
| Function | "function":"DistinctByKey" | DistinctByKey |
| Key Table | “p1”: “PrimaryTableName” | Required. The table that provides the join information for grouping the data on the target table. Must be a table that is linked to the target table. If the link [transactions].[cid] → [customer].[cid] exists, and [customer] is specified as the key table, data will be grouped by [cid] when calculating DistinctByKey. |
| Distinct Key | “p2”:"DistinctKeyName" | Required. The Field on the target table used to determine if a unique value has been found Within the key group, the first time a value is encountered it is flagged as 1, all other times it is flagged as 0. |
JSON Sample
Usage Notes

See Also:
- Engineering | Expression Field
Example
| Example | Details |
|---|---|
| Description | Flag Each unique instance of product-date-ns-2020, grouped by customer |
| Input |
|
| Sample | ![]() |
