How to calculate sum, minimum, maximum and average of several records
Use the “Calculate function“ mode of the [Read data] element for calculating various functions using the data from the records that match a filter. You can calculate the sum of values in a specific column for a number of records, as well as determine minimum, maximum or average value of a specific column. For example, you can calculate the total duration of activities of a specific employee for today.
To calculate a function, add the [Read data] element on the diagram and set up its properties (Fig. 1):
1.In the [Which data read mode to use?] field, select “Calculate function“.
2.In the [Which object to read data from?] field, select the object (section, detail or lookup). For example, to calculate the duration of activities, select the “Activity“ object.
3.In the [Function] field, select the function to use for calculation. For example, to calculate the total duration of activities, select “Sum”.
4.In the [By column] field, select the column by which the value must be calculated. For example, to calculate the total duration of activities, select the “Duration (minutes)” column. Only the columns that are compatible with the selected function will be available for selection.
5.In the [How to filter records?] block, specify filter conditions for record selection. The function will be calculated only for the columns that match the filter. For example, to calculate the functions only for the current user’s activities that are due today, set up the filter as shown on Fig. 1.
As a result, when the process is run, bpm’online will access the data of the specified object, get a list of records that match the filter, and calculate the specified function by the values of the specified column. The resulting value will be passed in the outgoing parameter of the [Read data] element.
See also