Formats a numeric set of values according to the specified number formatting. Source values can be a literal numeric value, a function returning a numeric value, or reference to a column containing an Integer or Decimal values.

NOTE: If the function is unable to process the value, a null value is returned on . On other running environments, trailing characters that do not apply to numeric values or their formatting are simply dropped.

supports a wide variety of number formats, following Java standards. For more information, please see Java's documentation.

NOTE: This function just changes how the underlying cell value is displayed. If you round the value to a specific level of precision, please use the ROUND function. See ROUND Function.

For more information on formatting date values, see DATEFORMAT Function.

Numformat(MyPrice, '$ ##,##.#', ',' ,'.')

Output: Returns the values from the MyPrice column by formatting the values using the specified formatting string and group and separators separators. For example, if the MyPrice column has a value of 12345.12 then it can be reformatted to $ 1,23,45.12 by using the above parameters.

Numformat(numeric_val, number_format_string, [grouping_separator], [decimal_separator])


ArgumentRequired?Data TypeDescription
numeric_valYstring, integer, or decimalLiteral value, function returning a numeric value, or name of Integer or Decimal column whose values are to be formatted
number_format_stringYstringLiteral value of the number formatting string used to indicate location of separators, number of required digits, currency, percentage, and sign.
grouping_separatorNstringA grouping representing grouping separator. By default, comma (,) is used as the grouping separator.
decimal_separatorN
stringA string representing decimal separator. By default, period (.) is used as the decimal separator.

numeric_val

Literal numeric value, a function that returns a numeric value, or the name of the column whose Integer or Decimal data is to be formatted.

Required?Data TypeExample Value
YesString (column reference), function, or Integer or Decimal literalMyPrice

number_format_string

String value indicating the number format to apply to the input values.

NOTE: You cannot create number format strings in which a 0 value appears before a # value. The following example strings are not supported: #.#0, #.#0#, #.#00

For more information on number formatting string options, see Supported Numeric Formatting.

Required?Data TypeExample Value
YesString'###.00'

grouping_separator

The string used to separate a group of digits. For example, a comma (,) is used as a grouping separator in the U.S.A (“10,000”), whereas space is used in France (“10 000”).

NOTE: If a space is used as the grouping separator, then any space values between a currency indicator and digits are automatically trimmed. A grouping separator should not be inserted between a currency indicator and a digit.


NOTE: Using invalid separators or wrong separators may generate errors in your recipe step.

Required?Data TypeExample Value
NoString','

decimal_separator

The string used to separate the integer part of a Decimal value from its fractional part. For example, a period(.) is used as a decimal separator in the U.S.A ("1234.12"), whereas comma (,) is used in France ("1234,12").



Required?Data TypeExample Value
NoString'.'


supports Java number formatting strings, with some exceptions.

Example - formatting price and percentages

This example steps through how to manage number formatting for price and percentage data when you must perform some computations on the data in the application.

Source:

In this case, you need to compute sub-total and totals columns.

OrderIdQtyUnitPriceDiscountTaxRate
10015$25.000%8.25%
100215$39.995%8.25%
10032$99.9915%8.25%
1004100$999.990%8.25%

Transformation:

When this data is first imported into the Transformer page, you might notice the following:

NOTE: Where possible, remove currency and three-digit separators from your numeric data prior to import.

You can re-type the OrderId column to String without issue. If you retype the other three columns, all values are mismatched. You can use the following transforms to remove the currency and percentage notation. The first transform removes the trailing % sign from every value across all columns using a .

You can use a similar one to remove the $ sign at the beginning of values:

When both are applied, you can see that the data types of each column is updated to a numeric type: Integer or Decimal. Now, you can perform the following computations:

You can use the new SubTotal column as the basis for computing the DiscountedTotal column, which factors in discounts:

The Total column applies the tax to the DiscountedTotal column:

Because of the math operations that have been applied to the original data, your values might no longer look like dollar information. You can now apply price formatting to your columns. The following changes the number format for the SubTotal column:

Note that the leading $ was not added back to the data, which changes the data type to String. You can apply this transform to the Price, DiscountedTotal, and Total columns.

NOTE: The data types for your columns should match the expected inputs for your downstream analytics system.

The Discount and TaxRate values should be converted to Decimals. The following adjusts the Discount column:

Results:

The output data should look like the following:

OrderIdQtyUnitPriceSubTotalDiscountDiscountedTotalTaxRateTotal
1001525.00125.000125.000.0825135.31
10021539.99599.850.05569.860.0825616.87
1003299.99199.980.15169.980.0825184.01
1004100999.9999999.00099999.000.0825108248.92

See Also