Excel LEFT Function
The LEFT function in Microsoft Excel extracts a specified number of characters from the start of a text string. It is useful for parsing data, such as extracting prefixes or initial characters from codes or names.
Key Topics
Overview of LEFT Function
The LEFT function retrieves characters from the beginning of a text string, based on the number specified. It is commonly used in data cleaning or to extract specific portions of text, like area codes or product IDs.
LEFT Function Syntax
The syntax for the LEFT function is as follows:
Syntax: =LEFT(text, [num_chars])
Parameters:
- text: The text string to extract from (required).
- num_chars: The number of characters to extract (optional; defaults to 1).
Implementation Examples
Below are examples of how to use the LEFT function in different scenarios.
Example 1: =LEFT(A2, 3)
— Extracts the first 3 characters from A2.
Example 2: =LEFT(B2)
— Extracts the first character from B2 (default num_chars=1).
Example 3: =LEFT(A2, FIND(" ", A2)-1)
— Extracts characters before the first space in A2.
Sample Dataset (Excel-style View)
Below is a demo dataset styled like Excel, showing how the LEFT function can be used to extract product codes.
A | B | |
---|---|---|
1 | Product ID | Category Code |
2 | LAP12345 | =LEFT(A2, 3) |
3 | PHN67890 | =LEFT(A3, 3) |
4 | TAB45678 | =LEFT(A4, 3) |
5 | MON11223 | =LEFT(A5, 3) |
6 | PRT33445 | =LEFT(A6, 3) |
Note: In the dataset, column B uses =LEFT(A2, 3)
to extract the first three characters from the Product ID in A2, representing the category code (e.g., LAP for Laptop). The formula is applied to each row for consistent extraction.
Key Takeaways
- The LEFT function extracts characters from the start of a text string.
- It requires a text string and optionally the number of characters to extract.
- It can be combined with FIND for dynamic extractions, e.g., before a space.
- Common uses include parsing codes, names, or identifiers.
- The sample dataset demonstrates LEFT applied to extract product category codes.