AVERAGE_BYINDEX

Takes all the child records for each parent that match the optional filter criteria and fall within the specified index, and sums the values. Then divides the sum by the number of child records that matched the criteria for each parent. The value returned is the average for each parent record.

AVERAGE_BYINDEX ( <field_name>, Index [, <orderby field>] [, <filter_query>] )
  • field_name: A numeric field to be used in the calculation of the average.

  • index: The number of records to use in the calculation.

  • orderby field_name: The field to sort each parents child records by.

  • filter_query: A query string represents the records to include include in the calculation.

Example: Create a field at the CUSTOMER level to return the average cost of the first 3 products sorted in Product Value order where the Product Code is "B".

AVERAGE_BYINDEX( [PRODUCT.PRODUCT_VALUE],3,[PRODUCT.PRODUCT_VALUE],[PRODUCT.PRODUCT_CODE] = "B" )