Binary.View

Binary.View

D

The M Code Behind the Power Query M function Binary.View

The Binary.View function is used to convert binary data to a text representation. This function is used to view the raw data in a binary format. In this article, we will explore the M code behind the Power Query M function Binary.View.

Understanding Binary Data

Binary data is data that is represented in binary code, which is a series of 1s and 0s. It is a way of representing data using only two digits. Binary data is used in many applications, including computer networking, cryptography, and file formats such as images, audio, and video.

In Power Query, binary data can be represented as a binary type value. This type of value contains binary data that can be converted to text using the Binary.View function.

The M Code Behind Binary.View

The Binary.View function is used to convert binary data to a text representation. It takes a binary type value as its input and returns a text value that represents the binary data in a readable format. The M code behind this function is simple and can be written as follows:

`Binary.View = (binary as binary) as text => Text.FromBinary(binary)`

This code defines the Binary.View function as a lambda function that takes a binary type value as its input and returns a text value that represents the binary data. The Text.FromBinary function is used to convert the binary data to text.

Using Binary.View in Power Query

To use the Binary.View function in Power Query, you need to have binary data in your dataset. You can load binary data into Power Query using the Binary.From function. Once you have loaded your binary data, you can use the Binary.View function to view the raw data in a text format.

Here’s an example of how to use the Binary.View function in Power Query:

1. Load your binary data into Power Query using the Binary.From function.


let

Source = Binary.FromText(“01010100 01100101 01110011 01110100 00100000 01100111 01100001 01110010 01100010 01100001 01100111 01100101”, BinaryEncoding.Base2)

in

Source


2. Use the Binary.View function to view the binary data in a text format.


let

Source = Binary.FromText(“01010100 01100101 01110011 01110100 00100000 01100111 01100001 01110010 01100010 01100001 01100111 01100101”, BinaryEncoding.Base2),

ViewBinary = Binary.View(Source)

in

ViewBinary


The output of this code will be "Test garbage", which is the text representation of the binary data "01010100 01100101 01110011 01110100 00100000 01100111 01100001 01110010 01100010 01100001 01100111 01100101".

The Binary.View function in Power Query is a powerful tool for converting binary data to a text representation. In this article, we explored the M code behind this function and how to use it in Power Query. With the Binary.View function, you can easily view the raw data in a binary format and perform data transformation and analysis tasks with ease.

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)

Copyright, G Com Solutions Ltd, 2024.
Tower Bridge Business Centre, 46-48 East Smithfield, London E1W 1AW
0800 998 9248   |   9:00 a.m. till 5:30 p.m.

Connect With Me: