Skip to content

Max_index

Maarten Hilferink edited this page Apr 8, 2026 · 7 revisions

Aggregation functions max_index

syntax

  • max_index(a)
  • max_index(a, relation)

definition

  • max_index(a) results in a parameter with the index numbers of the maximum value of the non null values of attribute a.
  • max_index(a, relation) results in an attribute with the index numbers of the maximum values of the non null values of attribute a, grouped by relation. The domain unit of the resulting attribute is the values unit of the relation.

description

The max_index function is not defined for string data items.

applies to

  • attribute a with Numeric, Point or boolean value type.
  • relation with value type of the group CanBeDomainUnit

conditions

The values unit of the resulting data item should be the domain unit of argument a.

since version

7.184

performance

  • Without relation: O(n) where n = number of elements in the domain of a. Single pass tracking maximum value and its index.
  • With relation: O(n) where n = number of elements in the domain of a. Tracks maximum value and index per group during a single pass.

example

parameter<Cit>  max_index_NrInh                := max_index(City/NrInhabitants); result = 0
attribute<City> max_index_NrInhRegion (Region) := max_index(City/NrInhabitants, City/Region_rel);
City/NrInhabitants City/Region_rel
550 0
525 1
300 2
500 1
200 3
175 null
null 3

domain City, nr of rows = 7

max_index_NrInhRegion
0
1
2
4
null

domain Region, nr of rows = 5

see also

Clone this wiki locally