Format currency with variable for locale and currency

This function takes a number and a locale as a parameter and formats it as a currency string based on the specified options.

Parameters

  • currency (number, required): the currency code to use for formatting the number. It must come from a variable (so a datasource) and not defined in the transformation itself.
  • locale (string, required): the locale to use for formatting the currency. It must come from a variable (so a datasource) and not defined in the transformation itself.
  • minDecimal (number, optional): the minimum number of decimal places to include in the formatted currency string. If not provided, the default minimum of 2 decimal places will be used.
  • maxDecimal (number, optional): the maximum number of decimal places to include in the formatted currency string. If not provided, the default maximum of 2 decimal places will be used.

Examples

format-currency(123456.789, "en-US", "USD")
# returns "$123,456.79"

format-currency(123456.789, "en-UK", "EUR", minDecimal=3, maxDecimal=3)
# returns "€123,456.789"

format-currency(123456.789, "fr-FR", "JPY", minDecimal=0, maxDecimal=0)
# returns "¥123,457"

format-currency(123456.789, "fr-CA", "CAD")
# returns "123 456,79 $CA"