Skip to main content
1 of 2
Adam Spriggs
  • 31.1k
  • 6
  • 44
  • 88

AMPScript is loosely typed. You may want to utilize the AttributeValue() functions so you can detect empty values in either number (using the empty() function). Here's how do to it:

%%[
var @price, @qty, @extPrice
/*
set @price = AttributeValue("price")
set @qty = AttributeValue("qty")
*/
set @price = "12.34"
set @qty = "3"

if empty(@price) or empty(@qty) then
  set @extPrice = "0.00"
else
  set @extPrice = multiply(@price,@qty)
endif

]%%
<br>extPrice: %%=formatNumber(@extPrice,D2)=%%

Output

extPrice: 37.02 

Reference

Adam Spriggs
  • 31.1k
  • 6
  • 44
  • 88