cardinality
Description
Returns the number of unique elements in an array.
- The element type must match the array type.
- Supported element types include
string
,bool
,number
,interval
,timestamp
,regexp
, andenum
.
Syntax
Like many functions in DataPrime, cardinality
supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.
Arguments
Name | Type | Required | Description |
---|---|---|---|
array | array | true | The array whose unique elements will be counted |
Example
Use case: Detect the number of unique IP addresses
Suppose you have a list of active IPs in a system. Consider the following input:
By applying cardinality
, you can determine how many unique IP addresses are present in the array.
Output
The result will include a new field unique_ip_count
showing the number of unique elements:
Theme
Light