frequency_table
Aggregation functions frequency_table
syntax
- frequency_table(a)
- frequency_table(a, relation)
definition
- frequency_table(a) results in a Parameter with a string listing all non-Null values of Attribute a together with how often each value occurs, separated by “; “.
- frequency_table(a, relation) results in an attribute with such strings, one per partition defined by relation. The Domain unit of the resulting attribute is the Values unit of the relation. Each partition string contains the value-count pairs for the non-null values of a belonging to that partition.
description
The result per partition is a string of the form value1: count1; value2: count2; ..., where:
- values are listed in ascending order (the order defined by the Values unit of attribute a),
- only values with a non-zero count are included,
- null values in a are excluded from the counts.
To include null values in the frequency table, use frequency_table_with_null instead.
applies to
- attribute a with any scalar Value type
- relation with value type of the group CanBeDomainUnit
conditions
- The domain of Argument a and relation must match.
since version
14.4.0
example
parameter<string> freqLifeStyleCode := frequency_table(City/LifeStyleCode);
// result = "0: 2; 1: 3; 2: 1"
attribute<string> freqLifeStyleCodePerRegion (Region) := frequency_table(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
| freqLifeStyleCodePerRegion |
|---|
| “2: 1” |
| “0: 2” |
| “1: 1” |
| “1: 1” |
| ”“ |
domain Region, nr of rows = 5
City 6 (LifeStyleCode = null) is excluded. City 5 (Region_rel = null) is excluded from all groups.
see also
- frequency_table_with_null - variant that includes null values of a in the frequency table
- asUniqueList - like frequency_table but only lists the distinct values, without the counts
- Modus - returns only the most frequently occurring value
- unique_count - returns the number of distinct non-null values