unique_count
Aggregation functions unique_count
syntax
- unique_count(a)
- unique_count(a, relation)
- unique_count_uint8/16/32/64(a)
- unique_count_uint8/16/32/64(a, relation)
definition
- unique_count(a) results in a Parameter with the number of different non Null values of Attribute a.
- unique_count(a, relation) results in an attribute with the number of different non null values of attribute a, grouped by relation. The Domain unit of the resulting attribute is the Values unit of the relation.
description
Values outside the range of the values unit of a are counted like any other value, as for Modus, also with relation where the counts are kept in a table.
applies to
- attribute a with uint2, uint4, uint8, uint16, uint32 or bool Value type
- relation with a value type that can be the type of a domain unit
conditions
- The values unit of the resulting Data item is the cardinal type of the values unit of a unless specified by the operator suffix.
- The domain of Argument a and relation must match.
since version
Values outside the range of the values unit of a also counted with relation since 20.23.1.
performance
The implementation is shared with the Modus function, see its performance section.
example 1
attribute<uint32> countLifeStyleCode (RegionDomain) := unique_count(City/LifeStyleCode, City/Region_rel);
| City/LifeStyleCode | City/Region_rel |
|---|---|
| 2 | 0 |
| 0 | 1 |
| 1 | 2 |
| 0 | 1 |
| 1 | 3 |
| 1 | null |
| null | 3 |
domain City, nr of rows = 7
| countLifeStyleCode |
|---|
| 1 |
| 1 |
| 1 |
| 1 |
| null |
domain Region, nr of rows = 5