Table of contents
TOC
Collapse the table of content
Expand the table of content

MID Function (DAX)

Owen Duncan|Last Updated: 5/22/2018

Returns a string of characters from the middle of a text string, given a starting position and length.

Syntax

MID(<text>, <start_num>, <num_chars>)  

Parameters

TermDefinition
textThe text string from which you want to extract the characters, or a column that contains text.
start_numThe position of the first character you want to extract. Positions start at 1.
num_charsThe number of characters to return.

Property Value/Return Value

A string of text of the specified length.

Remarks

Whereas Microsoft Excel has different functions for working with single-byte and double-byte characters languages, DAX uses Unicode and stores all characters with the same length.

Example

The following examples return the same results, the first 5 letters of the column, [ResellerName]. The first example uses the fully qualified name of the column and specifies the starting point; the second example omits the table name and the parameter, num_chars.

=MID('Reseller'[ResellerName],5,1))  
=MID([ResellerName,5])  

The results are the same if you use the following formula:

=LEFT([ResellerName],5)

See Also

Text Functions (DAX)

© 2018 Microsoft