This article explains how to use the TEXT()-function.

The TEXT() function is an extremely powerful utility for number formatting. In essence, the TEXT() function converts a number to its textual representation. However, its capabilities extend way beyond this basic use. The TEXT() function allows you to specify exactly the way a number needs to be formatted by applying format codes.

The syntax for the TEXT() function is as follows:

FS

TEXT(number, format_string)

number: A numerical value

format_string: A sequence of format codes enclosed within two quotation marks

Numbers

You can format numbers with a combination of the following codes:

# places a digit, if there is no digit to place it places nothing: ''

0 places a digit, if there is no digit to place it places a zero: '0'

? places a digit, if there is no digit to place it places a space: ' '

Moreover, you may also use spaces and/or supporting symbols in your format.

All integer digits will always be included in the final string, but you can decide how many decimal digits the result will have.

To include the decimal part of a number, you need to include a decimal separator. The decimal separator is the first period (.) or comma (,) from right to left in your format.

The TEXT() function also allows you to format numbers as percentages. This is achieved by adding a percentage symbol (%) in the format.

TEXT(0.8943, "0.00%")
"89.43%"

Fractions

Another type of number TEXT() supports is fractions. This format allows you to display any decimal number as a fraction. This a special format that needs to be in the following formats: "# ?/?", "# 4/?", "# ?/4".