Last
syntax
- last(a)
- last(a, relation)
definition
- last(a) results in a Parameter with the last of the non Null values of Attribute a.
- last(a, relation) results in an attribute with the last 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.
applies to
- attribute a with Numeric, Point, string or bool Value type
- relation with value type of the group CanBeDomainUnit
conditions
- The values unit of the resulting Data item should match with regard to value type and Metric with the values unit of attribute a.
- The domain of Argument a and relation must match.
performance
- Without relation: O(n) where n = number of elements in the domain of a. Scans entire domain to find last non-null value.
- With relation: O(n) where n = number of elements in the domain of a. Tracks last non-null value per group during a single pass.
example
parameter<uint32> lastNrInh := last(City/NrInhabitants); result = 175
parameter<string> lastCityName := last(City/CityName); result = ‘Haarlem’
parameter<bool> lastIsCap := last(City/IsCapital); result = False
attribute<uint32> lastNrInhRegion (Region):= last(City/NrInhabitants, City/Region_rel);
attribute<string> lastCityNameRegion (Region):= last(City/CityName, City/Region_rel);
attribute<bool> lastIsCapitalRegion (Region):= last(City/IsCapital, City/Region_rel);
| City/NrInhabitants | City/CityName | IsCapital | City/Region_rel |
|---|---|---|---|
| 550 | Amsterdam | True | 0 |
| 525 | Rotterdam | False | 1 |
| 300 | Utrecht | False | 2 |
| 500 | DenHaag | False | 1 |
| 200 | Eindhoven | False | 3 |
| 175 | Haarlem | False | null |
| null | null | False | 3 |
domain City, nr of rows = 7
| lastNrInhRegion | lastCityNameRegion | lastIsCapitalRegion |
|---|---|---|
| 550 | Amsterdam | True |
| 500 | DenHaag | False |
| 300 | Utrecht | False |
| 200 | Eindhoven | False |
| null | null | False |
domain Region, nr of rows = 5