Here’s how to use avg() function.
Description:
Compute the average value of the non-null members in a sequence.
Syntax:
A.avg() |
Equivalent to avg(x1,…,xn) |
Note:
The function computes the average value of the non-null members in a sequence, and is equal to A.sum()/A.count(). If the number of non-null members is 0, the average value will be null. Members that are not numerical values will be automatically skipped.
Parameters:
A |
A sequence |
Return value:
The average value of the non-null members in sequence A
Example:
|
A |
|
1 |
=[1,3,5,6].avg() |
3.75 |
2 |
=[2,null,4,3].avg() |
3.0 |
3 |
=[].avg() |
null |
4 |
=[2,4,3,"aaa"].avg() |
3.0 Skip members that are not numerical values |
5 |
=avg(2,null,4,3) |
3.0 |
Related functions:
Description:
Compute x with each member of the sequence and then compute the average value of the non-null members of the new sequence.
Syntax:
A.avg(x) |
Equivalent to A.(x).avg() |
Note:
The function computes x with each member of the sequence and returns the average value of the non-null members of the new sequence.
Parameters:
A |
A sequence |
x |
Generally an expression of a single field name, or a legal expression composed of multiple field names |
Return value:
Numerical values
Example:
|
A |
|
1 |
=demo.query("select * from EMPLOYEE") |
|
2 |
=A1.avg(SALARY) |
Compute the average value of non-null values of SALARY |
3 |
=A1.(SALARY+100).avg() |
Add 100 to each value of SALARY and then compute the average value |
Related functions: