AMPscript Math Functions
The math functions below allow us to add, subtract, divide, and multiply numbers in Marketing Cloud Emails, Landing Pages, SMS/MMS Messages, and Push Notifications. You can write complex math equations to calculate numbers on the fly using these functions.
- Add(N1,N2)
- Subtract(N1, N2)
- Multiply(N1, N2)
- Divide(N1, N2)
- Mod(N1, N2)
Add Function
The Add() function in AMPscript is used to add two numeric constants or two variables with a numeric value set.
Example
%%=Add(N1,N2)=%%
Subtract Function
The Subtract() function in AMPscript is used to subtract two numeric constants or two variables with a numeric value set.
Example
%%=Subtract(N1,N2)=%%
Multiply Function
The Multiply() function in AMPscript is used to multiply two numeric constants or two variables with a numeric value set.
Example
%%=Multiply(N1,N2)=%%
Divide Function
The Divide() function in AMPscript is used to divide two numeric constants or two variables with a numeric value set.
Example
%%=Divide(N1,N2)=%%
Mod Function
The Mod() function in AMPscript is used to find the remainder between two numeric constants or two variables with a numeric value set.
Example
%%=Mod(N1,N2)=%%
Hi Everyone! I hope this information helps. You can download the full code using the links below. Feel free to modify it to fit your needs. I’d love to get your feedback, did this information help in some way?
AMPscript Add Function
https://gist.github.com/nmaratasdev/594f7d9d0e4c0bae6f279baaaae2cade
AMPscript Subtract Function
https://gist.github.com/nmaratasdev/06748b1bf9f20da79bc35df386b86277
AMPscript Multiply Function
https://gist.github.com/nmaratasdev/f28a32fdc9c2f8aba8ab5fe701d3fed2
AMPscript Divide Function
https://gist.github.com/nmaratasdev/eead756b805739dd7e8c48542da339ef
AMPscript Mod Function
https://gist.github.com/nmaratasdev/973bf87cd432dfd90ef003d6a7a8b99a