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.

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)


ArgumentRequired?Data TypeDescription
column_stringYstringName of the column or string literal to be applied to the function
char_countYinteger (positive)Count of characters from the start of the value to include in the match

column_string

Name of the column or string constant to be searched.

Required?Data TypeExample Value
YesString literal or column referencemyColumn

char_count

Count of characters from the start of the string to include in the match.

Required?Data TypeExample Value
YesInteger (non-negative)5

Example - Driver's License Type

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:

LastNameLicenseID
AbleA1234567
BakerB5555555
CharlieC0123456

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:

LastNameLicenseIDleft_LicenseID
AbleA1234567A
BakerB5555555B
CharlieC0123456C

You can rename the new column to LicenseType.