Advanced Excel Statistical - TEXT Function



Description

The TEXT function converts a numeric value to text and lets you specify the display formatting by using special format strings.

This function is useful in situations where you want to display numbers in a more readable format, or you want to combine numbers with text or symbols.

Syntax

TEXT (value, format_text)

Arguments

Argument Description Required/ Optional
value A numeric value, a formula that evaluates to a numeric value, or a reference to a cell containing a numeric value. Required
format_text

A numeric format as a text string enclosed in quotation marks, for example "m/d/yyyy" or "#,##0.00".

The following sections provide you with specific formatting guidelines.

Required

Guidelines for Number Formats

Display decimal places and significant digits − To format fractions or numbers that contain decimal points, include the following digit placeholders, decimal points, and thousand separators in the format_text argument.

Sr.No Placeholder & Description
1

0 (zero)

Displays insignificant zeros if a number has fewer digits than there are zeros in the format.

2

#

Follows the same rules as the 0 (zero). However, Excel does not display extra zeros when the number that you type has fewer digits on either side of the decimal than there are # symbols in the format.

3

?

Follows the same rules as the 0 (zero). However, Excel adds a space for insignificant zeros on either side of the decimal point so that decimal points are aligned in the column.

4

. (period)

Displays the decimal point in a number.

Display a thousands separator − To display a comma as a thousands separator or to scale a number by a multiple of 1,000, include the following separator in the number format.

Sr.No Placeholder & Description
5

, (comma)

Displays the thousands separator in a number. Excel separates thousands by commas if the format contains a comma that is enclosed by number signs (#) or by zeros. A comma that follows a digit placeholder scales the number by 1,000.

Guidelines for Date and Time Formats

Display days, months, and years − To display numbers as date formats (such as days, months, and years), use the following codes in the format_text argument.

m Displays the month as a number without a leading zero.
mm Displays the month as a number with a leading zero when appropriate.
mmm Displays the month as an abbreviation (Jan to Dec).
mmmm Displays the month as a full name (January to December).
mmmmm Displays the month as a single letter (J to D).
d Displays the day as a number without a leading zero.
dd Displays the day as a number with a leading zero when appropriate.
ddd Displays the day as an abbreviation (Sun to Sat).
dddd Displays the day as a full name (Sunday to Saturday).
yy Displays the year as a two-digit number.
yyyy Displays the year as a four-digit number.

Display hours, minutes, and seconds − To display time formats (such as hours, minutes, and seconds), use the following codes in the format_text argument.

h Displays the hour as a number without a leading zero.
[h] Displays elapsed time in hours. If you are working with a formula that returns a time in which the number of hours exceeds 24, use a number format that resembles [h]:mm:ss.
hh Displays the hour as a number with a leading zero when appropriate. If the format contains AM or PM, the hour is shown based on the 12-hour clock. Otherwise, the hour is shown based on the 24-hour clock.
h Displays the hour as a number without a leading zero.
m

Displays the minute as a number without a leading zero.

The m or the mm code must appear immediately after the h or hh code or immediately before the ss code; otherwise, Excel displays the month instead of minutes.

[m] Displays elapsed time in minutes. If you are working with a formula that returns a time in which the number of minutes exceeds 60, use a number format that resembles [mm]:ss.
mm

Displays the minute as a number with a leading zero when appropriate.

The m or the mm code must appear immediately after the h or hh code or immediately before the ss code; otherwise, Excel displays the month instead of minutes.

s Displays the second as a number without a leading zero.
[s] Displays elapsed time in seconds. If you are working with a formula that returns a time in which the number of seconds exceeds 60, use a number format that resembles [ss].
ss Displays the second as a number with a leading zero when appropriate. If you want to display fractions of a second, use a number format that resembles h:mm:ss.00
AM/PM, am/pm, A/P, a/p Displays the hour based on a 12-hour clock. Excel displays AM, am, A, or a for times from midnight until noon and PM, pm, P, or p for times from noon until midnight.

Guidelines for currency, percentages, and scientific notation format

Include currency symbols − To precede a number with a dollar sign ($), type the dollar sign at the beginning of the format_text argument (for example, "$#,##0.00"). To enter one of the following currency symbols in a number format, press NUM LOCK and use the numeric keypad to type the ANSI code for the symbol.

You must use the numeric keypad; using the ALT key with the number keys in the top row of the keyboard will not generate ANSI codes.

To enter Use this key combination
¢ ALT+0162
£ ALT+0163
¥ ALT+0165
ALT+0128

Display percentages − To display numbers as a percentage of 100, include the percent sign (%) in the format_text argument.

Display scientific notations − To display numbers in scientific (exponential) format, use the following exponent codes in the format_text argument.

E (E-, E+, e-, e+) Displays a number in scientific (exponential) format. Excel displays a number to the right of the "E" or "e" that corresponds to the number of places that the decimal point was moved.

Guidelines for including Text and adding Spacing

If you include any of the following characters in the format_text argument, they are displayed exactly as entered.

$ Dollar sign
+ Plus sign
( Left parenthesis
: Colon
^ Circumflex accent (caret)
' Apostrophe
{ Left curly bracket
< Less-than sign
= Equal sign
- Minus sign
/ Slash mark
) Right parenthesis
! Exclamation point
& Ampersand
~ Tilde
} Right curly bracket
> Greater-than sign
Space character

The format_text argument cannot contain an asterisk (*)

Using the TEXT Function converts a numeric value to formatted text, and the result can no longer be calculated as a number

Notes

  • You can also format numbers by using the commands in the Number group on the Home tab of the Ribbon. However, these commands work only if the entire cell is numeric. If you want to format a number and combine it with other text, the TEXT Function is the best option.

  • If you omit the quotation marks from around the format_text argument, TEXT returns #NAME? error value.

Applicability

Excel 2007, Excel 2010, Excel 2013, Excel 2016

Example

TEXT Function
advanced_excel_statistical_functions.htm
Advertisements