BITLSHIFT

Updated on

BITLSHIFT is a DAX function that returns a number shifted left by a specified number of bits.

Syntax

BITLSHIFT(
   Number,
   ShiftAmount
)
Argument Properties Description
Number Any expression that represents an integer.
ShiftAmount Any expression that represents an integer as the number of bits to be shifted.

Return Values

An integer value.

Remarks

  • Be sure to understand the nature of bitshift operations and overflow/underflow of integers before using DAX bitshift functions.
  • If Shift_Amount is negative, it will shift in the opposite direction.
  • If absolute value of Shift_Amount is larger than 64, there will be no error but will result in overflow/underflow.
  • There’s no limit on Number, but the result may overflow/underflow.

Examples

Example 1

The following DAX query:

EVALUATE 
    { BITLSHIFT(2, 3) }

Returns 16.

Example 2

The following DAX query:

EVALUATE 
    { BITLSHIFT(128, -1) }

Returns 64.

Example 3

The following DAX query:

Define 
    Measure Sales[LeftShift] = BITLSHIFT(SELECTEDVALUE(Sales[Amount]), 3)

EVALUATE 
SUMMARIZECOLUMNS(
    Sales[Amount],
    "LEFTSHIFT", 
    [LeftShift]
)

Shifts left each sales amount with 3 bits and returns the bit-shifted sales amount.

Other functions related to BITLSHIFT are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/dax/bitlshift-function-dax

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy