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.
Related articles
Learn more about Binary.ToList in the following articles:
- Converting HEX to RGB Values in Power Query M
This article explains the conversion process of HEX values into RGB. » Read more
Related functions
Other functions related to Binary.ToList are:
2023-2026 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy