BinaryFormat.ByteOrder
BinaryReturns a binary format with the byte order specified by the given format.
Syntax
BinaryFormat.ByteOrder(binaryFormat as function, byteOrder as number) as functionParameters
| Name | Type | Required | Description |
|---|---|---|---|
binaryFormat | function | Yes | The binary format to apply the byte order to. |
byteOrder | number | Yes | The byte order to use. Use ByteOrder.LittleEndian or ByteOrder.BigEndian. |
Return Value
function — A binary format function that reads data using the specified byte order.
Remarks
BinaryFormat.ByteOrder wraps a binary format to change its byte order (endianness). By default, multi-byte binary formats in Power Query use little-endian byte order (least significant byte first). Many network protocols and some file formats use big-endian byte order (most significant byte first) instead.
Use ByteOrder.BigEndian for big-endian data (network byte order) and ByteOrder.LittleEndian for little-endian data. This affects multi-byte integer and floating point format specifiers like BinaryFormat.UnsignedInteger16, BinaryFormat.SignedInteger32, BinaryFormat.Double, and similar formats.
Single-byte formats like BinaryFormat.Byte are unaffected by byte order since they read only one byte.
Examples
Example 1: Read a big-endian 16-bit unsigned integer
let
// Big-endian: most significant byte first
// 0x00, 0x01 = 1 in big-endian
binaryData = #binary({0x00, 0x01}),
format = BinaryFormat.ByteOrder(
BinaryFormat.UnsignedInteger16,
ByteOrder.BigEndian
)
in
format(binaryData)Example 2: Read a big-endian record
let
binaryData = #binary({
0x00, 0x01,
0x00, 0x00, 0x00, 0x02
}),
format = BinaryFormat.ByteOrder(
BinaryFormat.Record([
A = BinaryFormat.UnsignedInteger16,
B = BinaryFormat.UnsignedInteger32
]),
ByteOrder.BigEndian
)
in
format(binaryData)