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.locale
(string, required): the locale to use for formatting the currency. It must comes 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", currency="USD")
# returns "$123,456.79"
format-currency(123456.789, "en-UK", currency="EUR", minDecimal=3, maxDecimal=3)
# returns "€123,456.789"
format-currency(123456.789, "fr-FR", currency="JPY", minDecimal=0, maxDecimal=0)
# returns "¥123,457"
format-currency(123456.789, "fr-CA", currency="CAD")
# returns "123 456,79 $CA"