MOD macro
The MOD
macro
is available in HCL®
Campaign and HCL
Interact.
Syntax
data MOD divisor data % divisor
Parameters
data
The
integer values to compute the modulo of. This 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 HCL
product.
divisor
The non-zero base
integer to compute the modulo in respect to. This can be a constant
value, a column, a cell range, or an expression evaluating to any
of the above. The number of columns in divisor
must
equal the number of columns in data
, unless divisor
is
a constant. For the format definition of divisor
(same
as data
), see the "Macro Function Parameters"
section in the chapter in this guide for your HCL
product.
Description
MOD
calculates
the remainder of dividing the specified data range by a specified
value. This is computed by dividing divisor
into
each value and returning the remainder. It returns one new column
for each input column, each containing the numbers in data
modulo divisor
.
The remainder will have the same sign (positive or negative) as data
.
If divisor
is
a constant, each value in the specified column is calculated modulo
that value. If divisor
is a column, the calculations
are performed on a row-by-row basis. The values in data
are
calculated modulo the first row value of divisor
,
the second row with the second row, and so on. This row-by-row calculation
produces a result for each row up to the last value of the shortest
column.
divisor
is zero,
a divide by zero error is returned.MOD
operator
can be abbreviated with the percent sign ( %
). For
example, TEMP
=
5 % 3
is
equivalent to TEMP
=
5 MOD
3
.Examples
TEMP = 10 MOD 8 or TEMP = 10 % 8 Creates
a new column named |
TEMP = -10 % 8 Creates a new column named |
TEMP = V1 % 8 Creates a new column named |
TEMP = V1:V3 % 2 Creates three new columns
named |
TEMP = V1 % V1 Creates a new column named |
TEMP = V1 % V2 Creates a new column named |
TEMP = V1:V3 % V4:V6 Creates three new columns
named |
TEMP = V1[10:20] % V2 or TEMP = V1[10:20]
% V2[1:11] Creates a new column named |
Related functions
Function | Description |
---|---|
DIV |
Divides one specified data range by another |
MOD |
Computes the modulo of the contents of the specified data range |