BITLSHIFT

How to Use the Power BI DAX function BITLSHIFT

What is BITLSHIFT?

BITLSHIFT stands for Bitwise Left Shift and is a mathematical operation used in computer programming. It takes two arguments, a number, and a shift amount, and shifts the bits of the number to the left by the specified shift amount.

How does BITLSHIFT work?

BITLSHIFT works by converting the number to a binary number and shifting the bits to the left by the specified shift amount. For example, if we have the number 5 (which is represented in binary as 101) and we want to shift the bits to the left by 2, the result will be 10100, which is equivalent to 20 in decimal notation.

How to use BITLSHIFT in Power BI

BITLSHIFT can be used in Power BI to perform bitwise left shift operations on numerical values. The syntax for the BITLSHIFT function is as follows:


BITLSHIFT(❰number❱, ❰shift amount❱)


Where `❰number❱` is the number you want to shift, and `❰shift amount❱` is the number of bits you want to shift the number to the left.

Let’s look at some examples of how to use BITLSHIFT in Power BI:

Example 1: Shifting a number by 1 bit

Suppose we have a table called `Sales` with a column called `Units Sold`. We want to create a new column called `Shifted Units Sold` that shifts the values in the `Units Sold` column to the left by 1 bit. We can do this using the following DAX formula:


Shifted Units Sold = BITLSHIFT(Sales[Units Sold], 1)


This will create a new column called `Shifted Units Sold` that contains the values in the `Units Sold` column shifted to the left by 1 bit.

Example 2: Shifting a number by multiple bits

Suppose we have a table called `Inventory` with a column called `Stock`. We want to create a new column called `Shifted Stock` that shifts the values in the `Stock` column to the left by 3 bits. We can do this using the following DAX formula:


Shifted Stock = BITLSHIFT(Inventory[Stock], 3)


This will create a new column called `Shifted Stock` that contains the values in the `Stock` column shifted to the left by 3 bits.

Example 3: Using BITLSHIFT in a measure

BITLSHIFT can also be used in measures to perform bitwise left shift operations on numerical values. For example, suppose we have a measure called `Total Sales`. We want to create a new measure called `Shifted Total Sales` that shifts the value of `Total Sales` to the left by 2 bits. We can do this using the following DAX formula:


Shifted Total Sales = BITLSHIFT([Total Sales], 2)


This will create a new measure called `Shifted Total Sales` that contains the value of `Total Sales` shifted to the left by 2 bits.

In this article, we discussed what BITLSHIFT is, how it works, and how to use it in Power BI. BITLSHIFT is a useful function for performing bitwise left shift operations on numerical values. By following the examples provided, you can easily incorporate BITLSHIFT into your Power BI reports and dashboards to enhance your data analysis capabilities.

Power BI DAX 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)