Number.BitwiseShiftLeft

Number

Shifts the bits of an integer left by a specified number of positions.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Number.BitwiseShiftLeft(number as number, shift as number) as number

Parameters

NameTypeRequiredDescription
numbernumberYesThe integer whose bits are shifted.
shiftnumberYesThe number of bit positions to shift left. Must be a non-negative integer.

Return Value

numberThe integer with bits shifted left by the specified number of positions.

Remarks

Number.BitwiseShiftLeft shifts the binary representation of number to the left by shift positions, filling the vacated low-order bits with zeros. Shifting left by n positions is mathematically equivalent to multiplying by 2^n — as long as the result does not overflow the 64-bit signed integer range.

This is the complement of Number.BitwiseShiftRight. Together, shift operations are used for:

- Constructing bitmasks: Number.BitwiseShiftLeft(1, n) creates a mask with only bit n set - Packing multiple values: shifting a value into position before OR-ing it into a packed integer - Fast powers of 2: computing 2^n efficiently (though Number.Power(2, n) is more readable for most cases)

The shift amount should be in the range 0–63 for 64-bit integers. Shifting by 0 returns the original value. The number value is treated as a 64-bit integer; any fractional part is truncated first.

Examples

Example 1: Shift 1 left by 3 positions — equivalent to 1 × 8

Result
Result
18

Example 2: Shift 3 left by 4 positions — equivalent to 3 × 16

Result
Result
148

Example 3: Build a bitmask with only bit 5 set

Result
Result
132

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks