Any valid expression that includes a field or a combination of fields from the current table or set that specifies what you want to average. Any type
Optional. When to use the function (instead of on every record).
Optional. When to reset the value produced by the function to 0 (instead at the end of all records). The Group and Sub_Group are optional parameters that define the range of records to summarize, and may or may not be required, depending upon the context of the summary calculation. Possible values for GRP >Group and GRP >Sub Group include:
- GRAND (all records)
- The name of the current table.
- The name of a table in the current set.
- The name of a grouping level that is defined in a report layout.
- DETAIL (over the records in the detail section).
Get the average of subexpression over group 'over' sampled each group 'each'
AVERAGE() returns the Average_Value of the Expression evaluated for a group of records. The Expression is evaluated for all the records in the sub-group that are related to the group's current record. The resulting values are then added together and the average value is returned. For example, to summarize the line-items in an invoice set, the Group parameter might be GRP >INVOICE and the Sub_Group parameter GRP >INV_ITEM. This means the Summarization operation includes only those child records in INV_ITEM related to the current parent record in the INVOICE table. To summarize all the records in a table or set, use the name GRAND as The Group name. The group GRP >GRAND and sub-group GRP >INV_ITEM produce a summary result based on all the invoices.
Assume that an invoicing set consists of two tables. One holds the invoices ( INVOICE ), and the other holds each invoice's line-items ( INV_ITEM ):
- CUST_ID and INV_TOTAL
INVOICE is related to INV_ITEM through a one-to-many link on the INV_NO field. To determine the average of line-item records for a particular invoice, use the following expression:
? average(INV_ITEM->AMOUNT, GRP >INVOICE, GRP >INV_ITEM) = 33.58, if the current INV_NO is "I102"
To determine the average of all line-item records for all INVOICE records, the expression is:
? average(INV_ITEM->AMOUNT, GRP >GRAND, GRP >INV_ITEM) = 41.93
This function is typically used in Reports to count records in a group, or in Forms to count records in a one-to-many child table.