Skip to main content
1 of 2
mlim
  • 11
  • 4

AMPscript formatting a number using a variable that needs TreatAsContent

I have a data ext that gives me a user's currency, plus fields for the cost that look like this: cost_USD | cost_EUR | cost_BRL

Here's what I have in my ampscript:

Set @partner_currency = partner_currency

Set @advertiser_email = advertiser_email

Set @variable_name = Concat('%%cost_',@partner_currency,'%%')

and within the body of the email: %%=TreatAsContent(@variable_name)=%%

This works perfectly to retrieve the data under the cost_xxx fields, which are all numbers. However, I need to format each number according to the country as well.

I'm trying to format them using %%=FormatNumber(@variable_name,"N2","en-US")=%% but of course since @variable_name needs the "TreatAsContent" to return the number and not the string name of the variable name, the formatting isn't working. Is there a way around this?

mlim
  • 11
  • 4