AMPscript Subtract (Next)
Subtract one number from another with AMPscript Subtract in Marketing Cloud Next. Syntax, examples, and behaviour proven in a Marketing Cloud Next email, including the argument forms that break the preview.
Syntax
Subtract(minuend, subtrahend) → number
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
minuend |
number | Yes | Value to subtract from |
subtrahend |
number | Yes | Value to subtract |
Exactly two arguments. Pass numeric literals or numeric variables: a number written as a string breaks the render in Next.
Example
%%=Subtract(50, 15)=%%
Renders 35.
A result below zero comes back as it is:
%%=Subtract(1.5, 2.25)=%%
Renders -0.75.
Return value
number — the first operand minus the second.
Every call that rendered gave a bare number. There is no set of special values to test for.
Behaviour
Exactly two arguments. An email that calls Subtract(50) or Subtract(50, 15, 1) cannot be saved: the content API answers HTTP 400 with “The AMPscript syntax isn’t valid”.
Decimals and negative results work. Subtract(10, 3) gives 7 and Subtract(1.5, 2.25) gives -0.75.
Numeric strings break the render. Subtract("50", "15") and Subtract("9", 4) both save, but the email preview then fails with HTTP 500 and no message. Convert string values first.
A negative first operand broke the render too. Subtract(-5, 3) saved but the preview failed with HTTP 500, so a negative literal as the first argument was not shown to work in Next.
Non-numeric input fails. Subtract("abc", 1) and Subtract("true", 1) each make the preview fail with HTTP 500.
Show Next test script
<!-- Marketing Cloud Next test script for Subtract. Paste it into the HTML component of a
Next email and open the preview. Each line prints the result Next gave when the call
was rendered on its own (expect) next to the result of this run (got).
Assembled from single-call test emails (dates on the page); it has not been
run as one email. Calls that make Next fail are listed separately. -->
<p>c1 expect=[7] got=[%%=Subtract(10,3)=%%]</p>
<p>c2 expect=[-0.75] got=[%%=Subtract(1.5,2.25)=%%]</p>
<p>c3 expect=[35] got=[%%=Subtract(50,15)=%%]</p>
Show calls that fail in Next (one email each)
<!-- Run each call below in its own Next email: one of them in a combined email
would stop the whole preview or block the save. -->
<!-- email 1: expect that the email saves, but the preview fails (HTTP 500) -->
%%=Subtract("50","15")=%%
<!-- email 2: expect that the email saves, but the preview fails (HTTP 500) -->
%%=Subtract("9",4)=%%
<!-- email 3: expect that the email saves, but the preview fails (HTTP 500) -->
%%=Subtract(-5,3)=%%
<!-- email 4: expect that the save is rejected (HTTP 400) -->
%%=Subtract(50)=%%
<!-- email 5: expect that the save is rejected (HTTP 400) -->
%%=Subtract(50,15,1)=%%
<!-- email 6: expect that the email saves, but the preview fails (HTTP 500) -->
%%=Subtract("abc",1)=%%
<!-- email 7: expect that the email saves, but the preview fails (HTTP 500) -->
%%=Subtract("true",1)=%%
Differs from official docs
- Negative first operand. The official reference allows positive and negative operands. In Next,
Subtract(-5, 3)saved, but the email preview failed with HTTP 500 (one probe). Details
Availability & differences
| Platform | Available |
|---|---|
| Marketing Cloud Engagement | Yes |
| Marketing Cloud Next | Yes, from API 67.0 |
Engagement accepts numeric strings (Subtract("50","15") gives 35, Subtract("9",4) gives 5) and renders Subtract(-5,3) as -8; in Next all three break the email preview. Compared 2026-11-23 by rendering the same calls in a Marketing Cloud Next email.
See also
Add— the inverse operationMultiplyDivide— the other two arithmetic functions- Official reference