FormatCurrency Function

The FormatCurrency function can be used to properly format number values to currency for your region.

Use case: you receive a number value from a data source with just number value, i.e. “123.4500”. You can use the FormatCurrency function to properly format this to $123.45. This can be applied to any ISO Country Codes compatible with Salesforce Marketing Cloud.

Syntax:



FormatCurrency(1,2,3,4)
1 = Numerical value to apply currency formatting
2 = ISO Country Code. See list of SFMC Compatible ISO Country Codes above
3 = Number of characters after the decimal place. Defaults to 2 characters. (optional)
4 = Symbol to prepend number which overrides ISO Country Code (optional)

Example:



%%[
set @numberValue = “1234.567”
]%%
%%=FormatCurrency(@numberValue,”en-us”)=%%




Output:

$1,234.57

Explanation:

In the FormatCurrency example above, we have a value of 1234.567. Note that the number of characters after the decimal place is 3 and we want to reduce that to 2 characters. We also want a dollar sign before the numbers so that the currency is formatted correctly.

The FormatCurrency function rounds the number up to “$1,234.57” and adds dollar sign and comma. Using the ISO Country Codes compatible with SFMC, this dollar sign can be changed to Yen or any other currency depending on the country, language or region. Note that the FormatCurrency function r can be used for whole numbers or decimals. The datatype for these values should be a number datatype or decimal or you can hardcode the numbers as it is shown in the example above.

Related function is the FormatNumber function.

2 comments

  1. I love all the post done by you, had lots of learning. Thank you!

    Just one correction, The output above might have Typo. Correct output will be: $1,234.57

Leave a Reply

Your email address will not be published. Required fields are marked *