Downloads
DAXTextBeginner

LEFT

Returns the first characters of a text value.

Syntax
LEFT(<text>, <num_chars>)

Returns: Text (a scalar).

What it does

LEFT returns the number of characters you ask for, counting from the start of the text. It is the simplest way to pull a prefix out of a code, such as the first digit of an account number that tells you whether it is an asset, a liability, equity, revenue or expense. The result is text, even when the characters look like a number.

Syntax and arguments

Example

Many charts of accounts use the first digit to group the accounts: 1 for assets, 2 for liabilities, 4 for revenue and 5 for expenses. The model needs an account class column for a summary.

Account Class =
SWITCH(
    LEFT(GL[AccountNumber], 1),
    "1", "Assets",
    "2", "Liabilities",
    "3", "Equity",
    "4", "Revenue",
    "5", "Expenses",
    "Other"
)

LEFT returns a text digit, so the comparisons use quoted text. Writing 4 without quotes would compare a number with text, which is a common error.

Example: a second, different use

Group invoice numbers by their year prefix, such as "2026-00142" starts with the year:

Invoice Year = LEFT(Invoices[InvoiceNumber], 4)

The year is text. If you need a number to filter or sort, wrap it in VALUE.

Things to watch

In business terms

LEFT is used to read chart of accounts classes, fiscal year prefixes on document numbers, region codes and product families from a code. Finance teams use it to group a mapping table before the group is used for a consolidation or a statutory return.

Related functions

All DAX functions · View as Markdown · DAX fundamentals