Multiply
Computes the product of two numeric values. Runtime-proven on a live Marketing Cloud Engagement CloudPage — including which argument types are accepted and which abort the page.
Syntax
Multiply(number1, number2) → number
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
number1 |
string | number | Yes | First operand |
number2 |
string | number | Yes | Second operand |
Example
%%[
VAR @lineTotal
SET @lineTotal = Multiply(3, 9.99)
]%%
Line total: %%=v(@lineTotal)=%%
Renders Line total: 29.97.
Percentages need the fraction spelled out, since there is no percent operator:
%%[
VAR @vat
SET @vat = Multiply(AttributeValue("NetAmount"), 0.19)
]%%
Return value
number — the product of the two operands.
Every successful call rendered a bare numeric literal. There is no closed set of status tokens or sentinel values.
Behaviour
Decimals and negatives work as expected. Multiply(1.5, 2.25) gives 3.375; Multiply(-5, 3) gives -15.
Numeric strings are accepted. Multiply("5", "3") gives 15, and mixing forms as in Multiply("4", 2.5) gives 10.
Non-numeric input aborts the page. A non-numeric string (Multiply("abc", 1)) and a boolean-like string (Multiply("true", 1)) each abort the CloudPage with HTTP 422, discarding all output rendered before the call.
No 32-bit truncation. Multiply(1000000, 1000000) returns 1000000000000, well past the signed 32-bit boundary, so large products are not clamped.
Show test script
%%[
VAR @b
SET @b = RequestParameter("b")
/* safe sweep: everything here is accepted and can share one request */
IF @b == "safe" THEN
OutputLine(Concat("Multiply(5,3)=[", Multiply(5,3), "]"))
OutputLine(Concat("Multiply('5','3')=[", Multiply("5","3"), "]"))
OutputLine(Concat("Multiply('4',2.5)=[", Multiply("4",2.5), "]"))
OutputLine(Concat("Multiply(1.5,2.25)=[", Multiply(1.5,2.25), "]"))
OutputLine(Concat("Multiply(-5,3)=[", Multiply(-5,3), "]"))
OutputLine(Concat("Multiply(1000000,1000000)=[", Multiply(1000000,1000000), "]"))
ENDIF
/* each risky branch aborts the page: the start marker never renders */
IF @b == "few" THEN
OutputLine(Concat("few start"))
OutputLine(Concat("Multiply(1)=[", Multiply(1), "]"))
ENDIF
IF @b == "many" THEN
OutputLine(Concat("many start"))
OutputLine(Concat("Multiply(1,2,3)=[", Multiply(1,2,3), "]"))
ENDIF
IF @b == "str" THEN
OutputLine(Concat("str start"))
OutputLine(Concat("Multiply('abc',1)=[", Multiply("abc",1), "]"))
ENDIF
IF @b == "bool" THEN
OutputLine(Concat("bool start"))
OutputLine(Concat("Multiply('true',1)=[", Multiply("true",1), "]"))
ENDIF
]%%
OutputLine given a bare string literal renders an empty line. Wrap the argument in Concat() or your start and done markers vanish silently — which looks exactly like the function failing.
Availability
| Platform | Available |
|---|---|
| Marketing Cloud Engagement | Yes |
| Marketing Cloud Next | Yes, from API 67.0 |
See also
Divide— the inverse operation, with an unusual zero-divisor resultAdd·Subtract— the other two arithmetic functions- Official reference · ampscript.guide