Average

<< Click to Display Table of Contents >>

Navigation:  Bizagi Studio > Process wizard > Business Rules > Business rules examples > Perform Math operations >

Average

Overview

This function obtains the average (arithmetic mean) of a set of numbers.

 

CHelper.Math.Average([Number1,Number2,...])

 

The parameter of this function is an array defined between brackets[], that can contain Xpaths, variables or numbers.

 

Considerations

The input parameter must be an array of doubles.

The supported attribute types to use as input XPath parameter (or Xpaths stored in variables) are: integer, currency, float, real.

The function returns an error if an empty input array is evaluated.

The function returns error if any input array is either too long or undefined.

Be careful when defining the input of the function to avoid errors for the end users.

Use the IsNaN function to validate the parameters used are numbers.

 

Example

In a Purchase Request Process an estimation of the price of a product is made based on the last three purchases of that product. The purchasing values are averaged to obtain an estimation. In Bizagi this estimation can be obtained using the Average function:

 

Math2

 

//Obtain the estimated price by averaging the last three purchasing prices

<Product.EstimatedPrice> = CHelper.Math.Average([<Product.Price1>,<Product.Price2>,<Product.Price3>])

 

//Alternative way

ArrayVariable=[<Product.Price1>,<Product.Price2>,<Product.Price3>]

<Product.EstimatedPrice> = CHelper.Math.Average(ArrayVariable)