#binary

Binary

Creates a binary value from a list of byte values or a base-64 encoded text string.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

#binary(value as any) as binary

Parameters

NameTypeRequiredDescription
valueanyYesEither a list of byte values (numbers 0–255) or a base-64 encoded text string.

Return Value

binaryA binary value constructed from the provided bytes or encoded text.

Remarks

#binary is M's literal constructor for creating binary values. It accepts either a list of byte values (integers 0–255) or a base-64 encoded text string.

Binary values in M represent raw byte sequences. They are primarily used when working with binary data sources such as files, streams, or web API responses that return non-text payloads.

When passing a text string, it must be valid base-64. Passing a list of integers outside the 0–255 range produces an error.

Examples

Example 1: Create a binary value from a list of bytes

#binary({72, 101, 108, 108, 111})
Result
Result
1SGVsbG8=

Example 2: Create a binary value from a base-64 string

#binary("SGVsbG8=")
Result
Result
1SGVsbG8=

Example 3: Round-trip binary to text and back

let
    Original = #binary({72, 101, 108, 108, 111}),
    Encoded  = Binary.ToText(Original),
    Decoded  = Binary.FromText(Encoded)
in
    Decoded
Result
Result
1SGVsbG8=

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks