Use this function to return the decimal average of a group of fields which have names that begin with common characters. The result of the operation is returned.
Avg (PartialName, Section, Form, Group)
Parameter |
Description |
PartialName |
Enter a valid string. The string must be the common (prefix) portion of a set of field names that occur on the current section. The default is the current field. |
Section |
Enter the name of a section that contains the field you specified. The default is the current section. |
Form |
Enter the name of a form that contains the section and/or field you specified. The default is the current form. |
Group |
Enter the name of the form group that contains the form, section, and/or field you specified. The default is the current group. |
The system and returns the average of the values of all fields that begin with the specified partial name.
An example of field names that have a common start are:
Myfield1
Myfield2
Myfield20
Each of these fields is included if you specify the partial name using any of the leading characters of myfield. The first field will be excluded if you enter myfield2, but will match the other two field names.
The average is calculated by summing those fields that have values and dividing by the number of those fields included in the sum. Note that zero (0) is a valid field value. Fields which have never been given a value are excluded from the calculation.
Note | Include the PartialName parameter. Fields must have unique names within a section. Using the default will probably not give the expected result, unless you created the form and understand the naming conventions. |
This table is used by the examples. The table shows the layout of two forms in the same group. Both forms share two sections (IMG A and IMG B). Each section has fields of the same name as a field in the other section.
Field |
Section |
Form |
Group |
Value |
MyField1 |
IMG A |
FRM A |
GRP |
100.24 |
MyField2 |
IMG A |
FRM A |
GRP |
200.16 |
MyField1 |
IMG B |
FRM A |
GRP |
98.60 |
MyField2 |
IMG B |
FRM A |
GRP |
* no value yet * |
MyField1 |
IMG A |
FRM B |
GRP |
0.00 |
MyField2 |
IMG A |
FRM B |
GRP |
* no value yet * |
MyField1 |
IMG B |
FRM B |
GRP |
70.77 |
MyField2 |
IMG B |
FRM B |
GRP |
* no value yet * |
Assume the current field is MyField1, on the first section of the first form. Reference the previous table for field values.
Function |
Result |
Explanation |
Return(AVG ( )) |
100.24 |
Without any other information, the function assumes the current field and section. There will only be one value included in the average. |
Return(AVG ("Myfield2")) |
200.16 |
Again, there is only one field included in this result. |
Return(AVG("MyField")) |
150.20 |
In this example, the current section contains two fields that begin with the name "MyField". The equation is as follows: (100.24 + 200.16) / 2 |
Return(AVG("MyField", "IMG B")) |
98.60 |
Although two fields on IMG B have a matching name, only one field actually has a value. |
Return(AVG("MyField", , "FRM A")) |
133.00 |
No section is specified in this example, so the entire form is searched. Four fields match the name criteria, but only three have values: (100.24 + 200.16 + 98.60) / 3 |
Return(AVG("MyField", "IMG B", , "GRP")) |
84.685 |
This example specifies a section and group, but no form. There are four fields that match the name criteria, but only two have values: (98.60 + 70.77) / 2 |
Return(AVG("MyField", , , "GRP")) |
93.954 |
This example names the group without a form or section. Eight fields meet the naming criteria, but only five fields actually have values: (100.24 + 200.16 + 98.60 + 0.00 + 70.77) / 5 |
© Copyright 2017, Oracle and/or its affiliates. All rights reserved. Legal Notices