Avg
This function is used to compute the average value of a list of numeric elements. It works on a list of elements that can be:
* Expressions.
* Arrays or sub-arrays of an array.
* Properties in an array of references.
avg(element_list)
element_list
is a list of elements
separated by commas.elements
can be:first_element
..last_element
. If several dimensions exist, the index range or the index values must be given for all dimensions.instance(first_element..last_element).property
.# Computes the average value of a list of computed valuesMY_RATE=max(CURRENT_CURRENCY_RATE, AVERAGE_COMPOUND_RATE, LEGAL_RATE)# average value on a matrix of values# We have NB_SALESREP sales representative in our department (NB_SALESREP<20)Local Decimal TURNOVER(1..12,1..20), AVERAGE_TURNOVERLocal Integer MONTH, SALESREP_ID# Fill the arrayFor MONTH=1 To 12For SALESREP_ID=1 To NB_SALESREPTURNOVER(MONTH,SALESREP_ID)=func GET_FIGURES(MONTH, SALESREP_ID)Next SALESREP_IDNext MONTH# Find out the average turnoverAVERAGE_TURNOVER=avg(TURNOVER(1..12,1..NB_SALESREP))
Decimal, integer, floating point, and double variables variables may be mixed.
If one of the arguments in the function is an array variable without specifying index or range of indexes all the variable elements are used. The specified index or range of indexes determines the elements to be considered.
At least one element must be present on the list. If a range of indexes is given such as there is no element to consider, a "division per zero" error is raised.