LEFT
The first characters of a text (one by default).
Group: Text. Compatible with DAX.
Syntax
LEFT ( <text> [, <num_chars>] )
| Parameter | Type | Description |
|---|---|---|
text | Text | The text to take characters from; a number becomes text first. |
num_chars | Whole number optional | How many characters to take; 1 when left out. |
Returns
Text. The first characters of the text.
Remarks
- Asking for more characters than the text has gives the whole text.
- A blank text gives BLANK. A negative number of characters is an error; a fraction is rounded, a half away from zero, so
LEFT ( "Bergen", 2.5 )is Ber. - Characters are counted as DAX counts them, so most emoji take two.
Examples
The first characters
EVALUATE
ROW (
"Six", LEFT ( "Bergen plant", 6 ),
"Left out", LEFT ( "abc" ),
"More than there are", LEFT ( "abc", 99 ),
"Of a number", LEFT ( 2026, 2 )
)
| Six | Left out | More than there are | Of a number |
|---|---|---|---|
| Bergen | a | abc | 20 |
The first word of each company
SEARCH finds the first space; a space added at the end makes it work for one-word names too.
EVALUATE
SELECTCOLUMNS (
Companies,
"Company", Companies[Company],
"First word", LEFT ( Companies[Company], SEARCH ( " ", Companies[Company] & " " ) - 1 )
)
ORDER BY [Company]
| Company | First word |
|---|---|
| Alnabru depot | Alnabru |
| Bergen plant | Bergen |
| Brewing | Brewing |
| Distribution | Distribution |
| Example Brewery Group | Example |
| Example Brewery Holding | Example |
| Oslo plant | Oslo |
| Trondheim plant | Trondheim |