OpenBI Docs Buy

LEFT

The first characters of a text (one by default).

Group: Text. Compatible with DAX.

Syntax

LEFT ( <text> [, <num_chars>] )
ParameterTypeDescription
textTextThe text to take characters from; a number becomes text first.
num_charsWhole 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 )
)
SixLeft outMore than there areOf a number
Bergenaabc20

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]
CompanyFirst word
Alnabru depotAlnabru
Bergen plantBergen
BrewingBrewing
DistributionDistribution
Example Brewery GroupExample
Example Brewery HoldingExample
Oslo plantOslo
Trondheim plantTrondheim

RIGHT, MID, LEN, SEARCH, FIND.

Last updated · OpenBI Studio 0.3.74