BinaryFormat.Transform

D

T

The M Code Behind the Power Query M function BinaryFormat.Transform

In this article, we will explore the M code behind the BinaryFormat.Transform function and how it can be used to transform binary data in Power Query.

What is Binary Data?

Binary data is a type of data that is represented in a binary format, which consists of only two digits, 0 and 1. It is commonly used in computer systems to represent data such as images, videos, audio files, and executable files. Binary data is often difficult to read and interpret, which is why it is necessary to convert it into a more readable format.

The BinaryFormat.Transform Function

The BinaryFormat.Transform function is a powerful function in Power Query M that allows you to convert binary data into different formats such as text, date, time, and number. It takes two arguments, the first argument is the binary data that you want to transform, and the second argument is the format that you want to transform the binary data into.

Here is the syntax of the BinaryFormat.Transform function:


BinaryFormat.Transform(binaryData as binary, format as text) as any


The first argument, binaryData, is the binary data that you want to transform. It must be provided as a binary value.

The second argument, format, is the format that you want to transform the binary data into. It must be provided as a text value. The format argument can be any of the following:

- "text": Converts the binary data into a text string.

- "date": Converts the binary data into a date.

- "time": Converts the binary data into a time.

- "datetime": Converts the binary data into a datetime.

- "datetimezone": Converts the binary data into a datetimezone.

- "duration": Converts the binary data into a duration.

- "number": Converts the binary data into a number.

How to Use BinaryFormat.Transform Function

To use the BinaryFormat.Transform function, you first need to load your binary data into Power Query. Once your data is loaded, you can apply the BinaryFormat.Transform function to the binary data to transform it into a different format.

Here is an example of how to use the BinaryFormat.Transform function to convert binary data into a text string:


let

binaryData = Binary.FromText(“Hello, World!”, BinaryEncoding.Base64),

textString = BinaryFormat.Transform(binaryData, “text”)

in

textString


In this example, we first convert the "Hello, World!" string into binary format using the Binary.FromText function. We then apply the BinaryFormat.Transform function to the binary data to convert it into a text string.

The BinaryFormat.Transform function is a powerful function in Power Query M that allows you to convert binary data into different formats. It is a useful tool for data transformation and analysis. In this article, we explored the M code behind the BinaryFormat.Transform function and how it can be used to transform binary data in Power Query.

Power Query and M Training Courses by G Com Solutions (0800 998 9248)

Upcoming Courses

Contact Us

    Subject

    Your Name (required)

    Company/Organisation

    Email (required)

    Telephone

    Training Course(s)

    Your Message

    Upload Example Document(s) (Zip multiple files)