0

I've put this AMPscript into an email to format the number field that I'm pulling in.

$%%=v(formatnumber(@%%Amount%%,"#,###")=%%

%%Amount%% in the record I'm proofing is 26000.0

However, it's formatting like this in the proofed email: $%%=v(formatnumber(@26000.0,"#,###")=%%

I'm sure it's a simple AMPscript error somewhere along the line. But I can't see where.

Thanks for your help.

1 Answer 1

2

The @ symbol is used to define the following text as a variable name in AMPscript.

It sounds like Amount is inside of your sendable DE, so you would not need the @ symbol. Also since it is inline, you do not need the %%.

You also have a v() wrapper, but no closing parenthesis on the end, which is throwing a syntax error. This v() wrapper is actually not needed either. This is more for displaying ampscript variable values, etc.

Here are a couple ways I would try this:

%%=FormatNumber(Amount,"#,###")=%% - but this will throw an error if the sendable data does not have a field named 'Amount'

%%=FormatNumber(AttributeValue("Amount"),"#,###")=%% - will provide empty result instead of error on no field existing.

Or a more comprehensive approach to handle empty values:

%%[ SET @Amount = AttributeValue("Amount")
    IF NOT EMPTY(@Amount) THEN
      SET @FormatAmount = FormatNumber(@Amount,"#,###")
    ELSE
      RaiseError('No Amount Defined')
    ENDIF
]%%
%%=v(@FormatAmount)=%%

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .