Purpose
Return value
Arguments
- text - The text from which to extract characters.
- num_chars - [optional] The number of characters to extract, starting on the left side of text. Default = 1.
Syntax
Usage notes
The LEFT function extracts a given number of characters from the left side of a supplied text string. The second argument, called num_chars, controls the number of characters to extract. If num_chars is not provided, it defaults to 1. If num_chars is greater than the number of characters available, LEFT returns the entire text string.
Examples
To extract the first three characters of "January":
=LEFT("January",3) // returns "Jan"
If the optional argument num_chars is not provided, it defaults to 1:
=LEFT("ABC") // returns "A"
If num_chars exceeds the string length, LEFT returns the entire string:
=LEFT("apple",100) // returns "apple"
When LEFT is used on a numeric value, the result is text:
=LEFT(1000,3) // returns "100" as text
The LEFT function is often combined with other functions like LEN and FIND to extract text in more complex formulas. For example, to split text at a specific character, use LEFT with the FIND function like this:
=LEFT(text,FIND(char,text)-1) // returns text to left of char
FIND returns the position of the character, and LEFT returns all text to the left of that position. Full explanation here.
Related functions
The LEFT function is used to extract text from the left side of a text string. Use the RIGHT function to extract text starting from the right side of the text, and the MID function to extract from the middle of text. The LEN function returns the length of text as a count of characters.
Notes
- num_chars is optional and defaults to 1.
- LEFT will extract digits from numbers as well as text.
- Number formatting is not counted or extracted.