Binary.ToList

Updated on

Binary.ToList is a Power Query M function that converts a binary value into a list of numbers. The function returns a list of numbers representing the binary value.

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

Syntax

Binary.ToList( binary as binary ) as list

Description

The Binary.ToList function takes a binary value and returns a list of numbers, where each number represents one byte from the buffer (0 – 255). You can use it to inspect or transform any individual bytes of any binary value.

Examples

One example that uses Binary.ToList is below code that transforms a HEX value into RGB:

let
    // Input hex color
    HexColor = "#26BFA3",

    // 1. Remove the leading “#”
    Clean = Text.TrimStart(HexColor, "#"),

    // 2. Parse the cleaned hex into a list of three byte values
    Bytes = Binary.ToList(Binary.FromText(Clean, BinaryEncoding.Hex)),

    // 3. Turn each byte into its decimal text form
    TextBytes = List.Transform(Bytes, each Text.From(_)),

    // 4. Join the three numbers with commas
    RGBText = Text.Combine(TextBytes, ", ")
in
    RGBText

This example uses the enumeration BinaryEncoding.Hex together with Binary.FromText to return a binary value from the original HEX value. Binary.ToList then splits the resulting value into the three elements to make up an RGB value. The code then concatenates these values into a single RGB value.

Learn more about Binary.ToList in the following articles:

Other functions related to Binary.ToList are:

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

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