BinaryFormat.7BitEncodedUnsignedInteger

D

T

The M Code Behind the Power Query M function BinaryFormat.7BitEncodedUnsignedInteger

Understanding the Basics of Binary Encoding

Before we dive into the specifics of the BinaryFormat.7BitEncodedUnsignedInteger function, it’s helpful to have a basic understanding of binary encoding. Binary encoding is a method of representing data using only two symbols: 0 and 1. These symbols are used to represent the two possible states of an electronic circuit, and they can be combined to represent any other data.

When we talk about binary encoding, we usually mean that we are representing data as a sequence of bits. A bit is either a 0 or a 1, and multiple bits can be combined to make up a byte. A byte is a group of 8 bits, and it can represent any integer value from 0 to 255.

What is the BinaryFormat.7BitEncodedUnsignedInteger Function?

The BinaryFormat.7BitEncodedUnsignedInteger function in Power Query allows you to convert a series of integers into a compressed binary format that is much more efficient to store and transmit than the original numbers. To use this function, you simply need to provide a list of integers and specify the number of bits to use for each integer.

The resulting binary data is encoded using a combination of 7-bit and 8-bit bytes. Each 7-bit byte is used to represent a single integer value between 0 and 127, while each 8-bit byte is used to represent an integer value between 128 and 255.

How Does the Function Work?

The M code behind the BinaryFormat.7BitEncodedUnsignedInteger function is relatively complex, but it can be broken down into a few basic steps. Here’s a high-level overview of how the function works:

1. First, the function converts each input integer into its binary representation. This is done using the Number.ToText function and specifying a base of 2.

2. Next, the function pads each binary representation with leading zeros until it is the specified number of bits long.

3. The function then groups the binary representations into sets of 7 bits each. If the last group has fewer than 7 bits, it is padded with zeros until it is exactly 7 bits long.

4. Each 7-bit group is then converted into an 8-bit byte by adding a leading bit with a value of 1. This is done to indicate that the byte is a 7-bit group rather than a regular 8-bit byte.

5. Finally, all of the 8-bit bytes are concatenated together to form the final compressed binary data.

Advantages of Using the BinaryFormat.7BitEncodedUnsignedInteger Function

The BinaryFormat.7BitEncodedUnsignedInteger function has several advantages over other methods of storing and transmitting integer data. Some of the main advantages include:

– Smaller File Sizes: Because the binary data is compressed, it takes up much less space than the original integer values. This can be a huge advantage when working with large datasets or transmitting data over a network.

– Faster Transmission: Because the compressed data is smaller, it can be transmitted more quickly than the original integer values. This can be especially important when working with real-time data or in situations where speed is critical.

– Increased Security: Because the compressed data is more difficult to read and understand than the original integer values, it can be more secure. This can be helpful when working with sensitive data that needs to be protected.

The BinaryFormat.7BitEncodedUnsignedInteger function in Power Query is a powerful tool for compressing and transmitting integer data. By understanding the M code behind this function and the basics of binary encoding, you can take full advantage of its capabilities and improve the efficiency and security of your data processing workflows.

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)