BinaryFormat.List

Updated on

BinaryFormat.List is a Power Query M function that reads a sequence of items from a binary format and returns a list. The number of items read is determined by countOrCondition, which can be a number, a function, or a binary format.

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

Syntax

BinaryFormat.List(
   binaryFormat as function,
   optional countOrCondition as any,
) as function

Description

Returns a binary format that reads a sequence of items and returns a list. The binaryFormat parameter specifies the binary format of each item. There are three ways to determine the number of items read:

  • If the countOrCondition is not specified, then the binary format will read until there are no more items.
  • If the countOrCondition is a number, then the binary format will read that many items.
  • If the countOrCondition is a function, then that function will be invoked for each item read. The function returns true to continue, and false to stop reading items. The final item is included in the list.
  • If the countOrCondition is a binary format, then the count of items is expected to precede the list, and the specified format is used to read the count.

Examples

Read bytes until the end of the data.

// Output: {1, 2, 3}
let
    binaryData = #binary( {1, 2, 3} ),
    listFormat = BinaryFormat.List( BinaryFormat.Byte )
in
    listFormat( binaryData )

Read two bytes.

// Output: {1, 2}
let
    binaryData = #binary( {1, 2, 3} ),
    listFormat = BinaryFormat.List( BinaryFormat.Byte, 2 )
in
    listFormat( binaryData )

Read bytes until the byte value is greater than or equal to two.

// Output: {1, 2}
let
    binaryData = #binary( {1, 2, 3} ),
    listFormat = BinaryFormat.List( BinaryFormat.Byte, ( x ) => x < 2 )
in
    listFormat( binaryData )

Other functions related to BinaryFormat.List are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/binaryformat-list

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy