FORMAT with a numeric argument
- Last UpdatedDec 19, 2022
- 2 minute read
The function formats a number according to the specified format mask.
Syntax
String FORMAT(x Float64, 'mask String')
Arguments
-
x
A numeric expression to format.
-
mask
Format-control string. See the following table.
Note: The FORMAT function also works with a DateTime argument. For more information, see FORMAT with a DateTime argument.
Mask options
The format mask may contain one or more of the following characters:
Character
Description
#
Each instance of the character represents a position for one digit. If no value exists in a position, an empty string is used in that position.
For example, if you specify a format of and have a value of 45, the function returns the number . If you have a value of 12145, the function returns , even though you defined only one placeholder to the left of the thousands separator.
0
Each instance of the character represents a position for one digit. If no value exists in a position, the function displays .
Thousands separators
Indicates that the thousands separators are used. The location of the separator in the mask does not determine the location of the separator in the result.
Decimal separator
Indicates that the decimal separator is used.
E, E+ , E-, e, e+, or e-
Represents values in scientific (exponential) notation. Use this option for very large or very small values. You must use these mask characters with other characters.
The or in the mask indicate that a plus or minus sign should always precede the exponent. The sign used is dependent on the actual value being formatted. If you do not use a plus or minus sign in the mask, a plus sign does not appear before the exponent; however, for small values, the negative sign is always included.
For example, if you specify a format of and have a value of 612345, the function returns . If you specify a format of and have a value of 98765, the function returns . If you specify a format of and have a value of 0.004567, the function returns .
g
Formats the number using the shortest possible format for the value.
Examples
-
- Returns
-
- Returns
-
- Returns
-
- Returns