Matches the leftmost set of characters in a string, as specified by parameter. The string can be specified as a column reference or a string literal. |
LEFT
function matches based on fixed numeric values, changes to the length or structure of a data field can cause your recipe to fail to properly execute.LEFT
function requires an integer value for the number of characters to match. If you need to match strings using patterns, you should use the STARTSWITH
transform instead. See STARTSWITH Function. Column reference example:
left(MyName,3) |
Output: Returns the first three letters of the MyName
column value.
String literal example:
left('Hello, World',5) |
Output: Returns the string: Hello
.
left(column_string,char_count) |
Argument | Required? | Data Type | Description |
---|---|---|---|
column_string | Y | string | Name of the column or string literal to be applied to the function |
char_count | Y | integer (positive) | Count of characters from the start of the value to include in the match |
Name of the column or string constant to be searched.
'Hello, World'
).
Required? | Data Type | Example Value |
---|---|---|
Yes | String literal or column reference | myColumn |
Count of characters from the start of the string to include in the match.
0
, then the match fails for all strings.Required? | Data Type | Example Value |
---|---|---|
Yes | Integer (non-negative) | 5 |
Source:
A California driver license number is one alphabetical character followed by seven digits (e.g., A1234567). The following is a set of California driver's license values:
LastName | LicenseID |
---|---|
Able | A1234567 |
Baker | B5555555 |
Charlie | C0123456 |
The LicenseID
value contains the license class as the first character of the value. For example, Baker's license is a Commercial Class B license.
Transformation:
To extract the license type into a separate column, you can use the following transformation:
Results:
LastName | LicenseID | left_LicenseID |
---|---|---|
Able | A1234567 | A |
Baker | B5555555 | B |
Charlie | C0123456 | C |
You can rename the new column to LicenseType
.