BinaryFormat.Binary
BinaryReturns a binary format that reads a binary value.
Syntax
BinaryFormat.Binary(optional length as any) as functionParameters
| Name | Type | Required | Description |
|---|---|---|---|
length | any | No | The number of bytes to read, or a binary format that reads the length preceding the binary data. If not specified, reads the remaining bytes. |
Return Value
function — A binary format function that reads a binary value of the specified length.
Remarks
BinaryFormat.Binary returns a binary format that reads a binary value from the input. The length parameter controls how many bytes are read:
- If
lengthis not specified, all remaining bytes in the binary stream are read. - If
lengthis a number, that exact number of bytes is read. - If
lengthis a binary format (such asBinaryFormat.ByteorBinaryFormat.UnsignedInteger32), the length value is read first from the stream using that format, and then that many bytes of binary data are read.
This is useful when extracting raw binary chunks from a larger binary stream, such as reading embedded images or binary blobs from a structured file format.
Examples
Example 1: Read a fixed number of binary bytes
let
binaryData = #binary({0x48, 0x65, 0x6C, 0x6C, 0x6F}),
format = BinaryFormat.Binary(2)
in
format(binaryData)Example 2: Read binary data with a length prefix
let
binaryData = #binary({3, 0x41, 0x42, 0x43, 0xFF}),
format = BinaryFormat.Binary(BinaryFormat.Byte)
in
format(binaryData)Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks