LEFT

Updated on

LEFT is a DAX function that returns a specified number of characters from the start of a text string.

Syntax

LEFT(
   Text,
   NumberOfCharacters
)
Argument Properties Description
Text The text string containing the characters you want to extract.
NumberOfCharacters Optional The number of characters you want LEFT to extract; if omitted, 1.

Return Values

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.

Example

The following example returns the first five characters of the company name in the column [ResellerName] and the first five letters of the geographical code in the column [GeographyKey] and concatenates them, to create an identifier.

= CONCATENATE(LEFT('Reseller'[ResellerName],LEFT(GeographyKey,3))

If the num_chars argument is a number that is larger than the number of characters available, the function returns the maximum characters available and does not raise an error. For example, the column [GeographyKey] contains numbers such as 1, 12 and 311; therefore the result also has variable length.

Other functions related to LEFT are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/dax/left-function-dax

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy