Updated on

BinaryFormat.Text is a function in the Power Query M language that reads a text value based on the specified length and encoding. The function returns a binary format that decodes the text using the provided parameters.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365


   length as any,
   optional encoding as nullable number,
) as function
Argument Attribute Description
encoding optional Uses the TextEncoding.Type to specify the text’s binary encoding format. By default, if not provided, the argument uses TextEncoding.Utf8 (UTF8 binary form). Other available options are:
TextEncoding.Unicode: use the UTF16 little-endian binary form.
TextEncoding.Utf16: use the UTF16 little-endian binary form.
TextEncoding.BigEndianUnicode: use the UTF16 big endian binary form.
TextEncoding.Windows: use the Windows binary form.
TextEncoding.Ascii: use the ASCII binary form.


Returns a binary format that reads a text value. The length specifies the number of bytes to decode, or the binary format of the length that precedes the text. The optional encoding value specifies the encoding of the text. If the encoding is not specified, then the encoding is determined from the Unicode byte order marks. If no byte order marks are present, then TextEncoding.Utf8 is used.


Decode two bytes as ASCII text.

// Output: "AB"
    binaryData = #binary( {65, 66, 67} ),
    textFormat = BinaryFormat.Text( 2, TextEncoding.Ascii )
    textFormat( binaryData )

Decode ASCII text where the length of the text in bytes appears before the text as a byte.

// Output: "AB"
    binaryData = #binary( {2, 65, 66} ),
    textFormat = BinaryFormat.Text( 
    textFormat( binaryData )

Other functions related to BinaryFormat.Text are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: