This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v19.8
collection.average( )
|
collection.average ( {propertyPath} ) -> Function result | ||||||||
Parameter | Type | Description | ||||||
propertyPath | Text |
![]() |
Object property path to be used for calculation | |||||
Function result | Real, Undefined |
![]() |
Arithmetic mean (average) of collection values | |||||
The collection.average( ) method returns the arithmetic mean (average) of defined values in the collection instance.
Only numerical elements are taken into account for the calculation (other element types are ignored).
If the collection contains objects, pass the propertyPath parameter to indicate the object property to take into account.
collection.average( ) returns Undefined if:
C_COLLECTION($col)
$col:=New collection(10;20;"Monday";True;6)
$vAvg:=$col.average() //12
C_COLLECTION($col)
$col:=New collection
$col.push(New object("name";"Smith";"salary";10000))
$col.push(New object("name";"Wesson";"salary";50000))
$col.push(New object("name";"Gross";"salary";10500))
$vAvg:=$col.average("salary") //23500
Product: 4D
Theme: Collections
Number:
705250
Created: 4D v16 R6
4D Language Reference ( 4D v19)
4D Language Reference ( 4D v19.1)
4D Language Reference ( 4D v19.4)
4D Language Reference ( 4D v19.5)
4D Language Reference ( 4D v19.6)
4D Language Reference ( 4D v19.7)
4D Language Reference ( 4D v19.8)