FirstDiscrete
  • 1 Minute to read
  • Dark
    Light
  • PDF

FirstDiscrete

  • Dark
    Light
  • PDF

Article summary

General: FirstDiscrete

Creates a flag field where the first occurrence of each unique value in the specified field is set to 1.

Purpose

Use this function to:
  • Gain a count of how many discrete values of a field there are in RecordSet
  • Identify one and only one occurrence of a particular field value within a 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":"firstdiscrete"FirstDiscrete
Distinct Field“p1”: “DistinctFieldName”Required.

Field on the target table to use when flagging first occurrence of a record.

All Field Types are always valid as Distinct Fields.

Continuous fields are usually valid, but because the FirstDiscrete operation is memory intensive, depending on the Table Size and DataType, it may not be possible to complete the operation.

Integer fields are always valid.

LongInteger fields are valid if Max - Min < 4 billion.

Continuous String fields depend on:

  • String Width
  • Discrete Values
  • Available memory

Continuous String fields will be slower than Integer or LongInteger fields.

To increase the ability of the system to perform FirstDiscrete operations, add more memory to the system. 

In general, ability increases with RAM.

Performance increases with the number of cores (as long as the system is using a Solid State disk, otherwise increasing the number of cores could degrade performance).

JSON Sample

{
  "method": "BuildBakedField",
  "project": "D3",
  "targetTable": "transactions",
  "overwrite": true,
  "name": "FD_cid",
  "function": "firstdiscrete",
  "p1": "cid"
}

Usage Notes

See Also:   

  • Engineering | Expression Field
  • DistinctByKey  (General Functions)
  • FirstDiscreteByIndex  (General Functions)

Example

ExampleDetails
DescriptionFlag first distinct occurrence of CID
Input
  • Table: = [transactions]
  • Filter: = [No Filter]
  • Function: = FirstDiscrete
  • Distinct Field:= cid
  • Name: =FD_cid
Sample





Was this article helpful?