AVG macro
The AVG
macro
is available in Unica Campaign and Unica Interact.
Syntax
AVG(data [, keyword])
Parameters
data
The numerical values for which to compute the
arithmetic mean. These values can be a constant value, a column, a
cell range, or an expression evaluating to any of the above. For the
format definition of data
, see the "Macro Function
Parameters" section in the chapter in this guide for your product.
keyword
This optional keyword determines how the computation is performed over the input data range. Select one of the following keywords:
ALL
 Performs the computation on all cells
in data
(default)
COL

Performs the computation separately for each column of data
ROW
 Performs the computation separately
for each row of data
For more details on using keywords in Unica Campaign, see Format Specifications.
{ALL  COL  ROW}
. These
keywords do not apply in Unica Campaign because
the input data is always a single column or field. The macro always
behaves as if the COL
keyword were specified. Therefore,
you do not need to specify these keywords when you use Unica Campaign.Description
AVG
calculates
the arithmetic mean or average of the cells in the specified data
range. The arithmetic mean is calculated by summing the contents of
all cells, then dividing the result by the number of cells. The number
of columns that are returned by AVG
depends on keyword
.
 If
keyword
isALL
,AVG
returns one new column, containing a single value (the average of all cells indata
).  If
keyword
isCOL
,AVG
returns a new column for each input column. Each new column contains one value (the average of all cells in the corresponding input column).  If
keyword
isROW
,AVG
returns one new column that contains the average across each row ofdata
.
AVG
is the same as the MEAN
macro function.Examples
TEMP = AVG(V1)
Creates a column named TEMP containing a single value that is the arithmetic mean of the contents of column V1. 
TEMP = AVG(V1:V3)
Creates a column named TEMP containing a single value that is the arithmetic mean of the contents of columns V1, V2, and V3. 
TEMP = AVG(V1[10:20])
Creates a column named TEMP containing a single value that is the arithmetic mean of the cells in rows 1020 of column V1. 
TEMP = AVG(V1[1:5]:V4)
Creates a column named TEMP containing a single value that is the arithmetic mean of the cells in rows 15 of columns V1 through V4. 
TEMP = AVG(V1:V3, COL)
Creates three new columns named TEMP, VX, and VY. The single value in the TEMP column is the arithmetic mean of the contents of column V1. The single value in the VX column is the arithmetic mean of the contents of column V2. The single value in the VY column is the arithmetic mean of the contents of column V3. 
TEMP = AVG(V1[1:5]:V3, COL)
Creates three new columns named TEMP, VX, and VY, each containing a single value. The value in column TEMP is the arithmetic mean of the cells in rows 15 of column V1. The value in column VX is the arithmetic mean of the cells in rows 15 of column V2. The value in column VY is the arithmetic mean of the cells in rows 15 of column V3. 
TEMP = AVG(V1, ROW)
Creates a column named TEMP, containing the same values as column V1 (the arithmetic mean of any number is itself). 
TEMP = AVG(V1:V3, ROW)
Creates a column named TEMP where each cell entry is the arithmetic mean of the corresponding row across columns V1, V2, and V3. 
TEMP = AVG(V1[1:5]:V3, ROW)
Creates a column named TEMP, where the cells in rows 15 contain the arithmetic mean of the corresponding row across columns V1 through V3. The other cells in TEMP are empty. 
Related functions
Function  Description 

SUM or TOTAL 
Computes the sum of a range of cells 