Sum, Multiply and Average Fields in a Collection with CollectionCalculate

We’ve added an action called CollectionCalculate to the CollectionProcessors package that lets you provide a collection of records, specify a field by name, and indicate whether you’d like to add, multiply or average the values. The result is returned both as a decimal and a string.

Input Attributes

inputCollectiona collection of SObjects
fieldNamethe name of a field on the objects that you’re passing in
operationallowable values: “Average”, “Add”, “Multiply”
policyForNullAndEmptyFieldsString. Allowable Values: “use0”, “use1”. If any other value is used or if this attribute is null, an empty field or null value in one of the passed in records will cause the action to fail. ‘use0’ replaces empty and null fields with zero and ‘use1’ replaces them with 1

Install

Available in version 1.28 and later of CollectionProcessors

Source

source