Edit

LEFT

Applies to: Calculated column Calculated table Measure Visual calculation

Returns the specified number of characters from the start of a text string.

Syntax

LEFT(<text>, <num_chars>)

Parameters

Term Definition
text The text string containing the characters you want to extract, or a reference to a column that contains text.
num_chars (optional) The number of characters you want LEFT to extract; if omitted, 1.

Return value

A text string.

Remarks

  • Whereas Microsoft Excel contains different functions for working with text in single-byte and double-byte character languages, DAX works with Unicode and stores all characters as the same length; therefore, a single function is enough.

  • This function is not supported for use in DirectQuery mode when used in calculated columns or row-level security (RLS) rules.

  • This function returns different results depending on the UnicodeCharacterBehavior setting of your model.

Example

Examples in this article can be used with the sample Adventure Works DW 2020 Power BI Desktop model. To get the model, see DAX sample model.

The following example returns the first five characters of the company city in the column [City] and the first five letters of the reseller key in the column [ResellerKey] and concatenates them, to create an identifier.

=
CONCATENATE (
    LEFT ( 'Reseller'[City], 5 ),
    LEFT ( 'Reseller'[ResellerKey], 5 )
)

If the num_chars argument is larger than the number of characters available, the function returns the maximum characters available and doesn't raise an error. For example, the column [ResellerKey] contains numbers such as 5, 24, and 312, so the result also has variable length.