Skip to content

modus_count

MaartenHilferink edited this page Oct 7, 2026 · 6 revisions

Aggregation functions modus_count

syntax

  • modus_count_uint8/16/32/64(a)
  • modus_count_uint8/16/32/64(a, relation)

definition

  • modus_count_uint8/16/32/64(a) results in a parameter with the number of occurrences of the most occurring non null value of attribute a, in other words the frequency of the modus.
  • modus_count_uint8/16/32/64(a, relation) results in an attribute with the number of occurrences of the most occurring non null value of attribute a, grouped by relation. The domain unit of the resulting attribute is the values unit of the relation.

description

  • The suffix of the function name determines the value type of the resulting data item: uint8, uint16, uint32 or uint64. There is no modus_count function without a suffix, so choose a variant that can contain the highest frequency that can occur.
  • If attribute a contains no non null values (for a group), the resulting count is 0, whereas the modus function results in null in that case.
  • Values of an integer value type outside the range of the values unit of a are counted like any other value, as for modus (since 20.23.1 also with relation where the counts are kept in a table; before, that case left them out).

applies to

  • attribute a with a numeric or string value type
  • relation with a value type of the group CanBeDomainUnit

conditions

  1. The domain of argument a and relation must match.

Since GeoDMS 20.23.1 a count that does not fit the value type of the result is an error, as it is for count_uint8 and count_uint16. Before, modus_count_uint8 of 300 equal values resulted in 44.

performance

The implementation is shared with the modus function, see its performance section.

example

parameter<uint32> modusCountLifeStyleCode                      := modus_count_uint32(City/LifeStyleCode); result = 3
attribute<uint32> modusCountLifeStyleCodeRegion (RegionDomain) := modus_count_uint32(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

modusCountLifeStyleCodeRegion
1
2
1
1
0

domain Region, nr of rows = 5

The most occurring non null value of the whole attribute is 1, occurring 3 times. In region 1 the value 0 occurs twice. Region 4 has no related rows, resulting in a count of 0.

see also

Clone this wiki locally