This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v19.8
entitySelection.sum( )
|
entitySelection.sum ( attributePath ) -> Result | ||||||||
Parameter | Type | Description | ||||||
attributePath | Text |
![]() |
Path of the attribute to be used for calculation | |||||
Result | Real |
![]() |
Sum of entity selection values | |||||
The entitySelection.sum( ) method returns the sum for all attributePath values in the entity selection.
entitySelection.sum( ) returns 0 if the entity selection is empty.
The sum can only be done on values of number type. If the attributePath type is object, only numerical values are taken into account for the calculation (other value types are ignored). In this case, if attributePath leads to a property that does not exist in the object or does not contain any numeric values, entitySelection.sum( ) returns 0.
An error is returned if:
C_OBJECT($sel)
C_REAL($sum)
$sel:=ds.Employee.query("salary < :1";20000)
$sum:=$sel.sum("salary")
Product: 4D
Theme: ORDA - EntitySelection
Created: 4D v17
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)