BinaryFormat.Length is a Power Query M function that limits the amount of data read by a binary format. It takes a binary format and a length parameter, and it returns a limited binary format that reads the specified number of bytes.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
BinaryFormat.Length(
binaryFormat as function,
length as any,
) as function
Description
Returns a binary format that limits the amount of data that can be read. Both BinaryFormat.List and BinaryFormat.Binary can be used to read until end of the data. BinaryFormat.Length can be used to limit the number of bytes that are read. The binaryFormat parameter specifes the binary format to limit. The length parameter specifies the number of bytes to read. The length parameter may either be a number value, or a binary format value that specifies the format of the length value that appears that precedes the value being read.
Examples
Limit the number of bytes read to 2 when reading a list of bytes.
// Output: {1, 2}
let
binaryData = #binary( {1, 2, 3} ),
listFormat = BinaryFormat.Length(
BinaryFormat.List( BinaryFormat.Byte ),
2
)
in
listFormat( binaryData )
Limit the number of byte read when reading a list of bytes to the byte value preceding the list.
// Output: {2}
let
binaryData = #binary( {1, 2, 3} ),
listFormat = BinaryFormat.Length(
BinaryFormat.List( BinaryFormat.Byte ),
BinaryFormat.Byte
)
in
listFormat( binaryData )
Related functions
Other functions related to BinaryFormat.Length are:
- BinaryFormat.Byte
- BinaryFormat.Choice
- BinaryFormat.Decimal
- BinaryFormat.Double
- BinaryFormat.Null
- BinaryFormat.Single
- BinaryFormat.Text
2023-2026 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy