Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Added code tags and Marketing Cloud tag
Source Link
Rain
  • 5.8k
  • 6
  • 23
  • 45

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

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,'%%')

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)=%%

%%=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")=%%%%=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?

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?

I have a data extension 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?

Source Link
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?