AGGREGATEFUNCTION

AGGREGATEFUNCTION is used to retrieve values from arrays according to specified functions. Functions include counting elements, summing elements and retrieving specific element data from the array.

AGGREGATEFUNCTION: Elements and Attributes
TYPE=AGGREGATEFUNCTION
Element Attribute Element/Attribute Value Result

<MathVariable>

 

 

 

 

 

 

 

 

 

 

The name of a previously defined array.

 

VARIABLENAME

String

TYPE

AGGREGATEFUNCTION

 

METHOD

 

COUNT

Returns the number of elements in the array.

EXISTS

Returns 1 if the specified value exists in the array, or 0 if it does not.

LOOKUP

Integer. Required attribute for METHOD="EXISTS".

 

 

INDEX

Returns specific data from position provided by an additional attribute, INDEX. Whatever the means to provide INDEX with a value, it must be a positive integer less than the number of elements in the array. If not, an exception will occur.

INDEX

 

 

Integer. Required attribute for METHOD="INDEX".

 

SUM

Returns the sum of all the elements in the array. The elements of the array must be one of the numeric data types.

SUMSCALE

 

Returns the sum of all numbers in the given array multiplied by the value of the SCALE attribute.

MAX

Returns the highest element value in the array.

MIN

Returns the lowest element value in the array.

TOSTRING

Returns the array in string form.

INDEXOF

 

Returns the specified item in the array.

DATATYPE

For METHOD="INDEX" | "EXISTS" | "INDEXOF"BIGTEXT
DATE

TEXT
INTEGER
DECIMAL

 

For METHOD="COUNT" | "SUM" | "MIN" | "MAX"

INTEGER
DECIMAL

 

ROUND

Integer

Optional attribute for DATATYPE="DECIMAL"

 

DEFAULT

Optional attribute:

String.

Specifies default if return value is null.

 

LOG

Optional attribute: Yes or No.

Yes: the result is stored in AsActivityMath table to be used by other activities.

No: the result is not stored. This is the default behavior.  

 

CLEARVALUE

Value: Yes / No

Default Value: No

Optional attribute: 

Yes: The value of the math variable will be deleted after the execution of all the Attached Rules at the end of activity processing and will not be visible on the Math tab in the Activity details screen.

No: The value of the math variable will be retained after activity processing and will be displayed in the Math tab in the Activity details screen.

XML Schema

When METHOD="COUNT" or METHOD="SUM" or METHOD="MIN" or METHOD="MAX"

<MathVariable VARIABLENAME="[String]"
TYPE="AGGREGATEFUNCTION" METHOD="COUNT|SUM|MIN|MAX"
DATATYPE="INTEGER|DECIMAL" ROUND="[Integer]"
DEFAULT="[String]" LOG="Yes">[String]</MathVariable>

When METHOD="INDEX"

<MathVariable VARIABLENAME="[String]"
TYPE="AGGREGATEFUNCTION" METHOD="INDEX" INDEX="[Integer]"
DATATYPE="BIGTEXT|DATE|TEXT|INTEGER|DECIMAL" ROUND="[Integer]"
DEFAULT="[String]" LOG="Yes">[String]</MathVariable>

When METHOD="EXISTS|INDEXOF"

<MathVariable VARIABLENAME="[String]"
TYPE="AGGREGATEFUNCTION" METHOD="EXISTS|INDEXOF" LOOKUP="[Integer]" RETURNVALUES="[String]"
DATATYPE="DATE|TEXT|INTEGER|DECIMAL" ROUND="[Integer]"
DEFAULT="[String]" LOG="Yes">[String]</MathVariable>

XML Example

<MathVariable VARIABLENAME="SegmentCount" TYPE="AGGREGATEFUNCTION" METHOD="COUNT" DATATYPE="INTEGER">Segments</MathVariable>
<MathVariable VARIABLENAME="FunctionMax" TYPE="AGGREGATEFUNCTION" METHOD="MINOF" DATATYPE="INTEGER">ArrayName</MathVariable>
<MathVariable VARIABLENAME="FunctionMin" TYPE="AGGREGATEFUNCTION" METHOD="MAXOF" DATATYPE="INTEGER">ArrayName</MathVariable>
<MathVariable VARIABLENAME="LastPremiumYear" TYPE="AGGREGATEFUNCTION" METHOD="INDEX" INDEX="PremiumIterations-1" DATATYPE="INTEGER">PremiumYearArray</MathVariable>