DistinctByKey
  • 1 Minute to read
  • Dark
    Light
  • PDF

DistinctByKey

  • Dark
    Light
  • PDF

Article summary

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

PropertyValue
FieldTypeInteger
FieldSizeLow
DataTypeDiscrete 
DataSizeByte


Example Return Value: 0 , 1, null


Parameters

ParameterJSONDescription
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

ExampleDetails
DescriptionFlag Each unique instance of product-date-ns-2020, grouped by customer
Input
  • Table: = transactions
  • Filter:= [No Filter]
  • Function: = DistinctByKey
  • Key Table: = customer
  • Distinct Key:=[transactions].[product-date-ns-2020]
  • Name = distinct_pr-date-ns-2020
Sample





Was this article helpful?

What's Next