Number.BitwiseShiftRight

Number

Shifts the bits of an integer right 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.BitwiseShiftRight(number as number, shift as number) as number

Parameters

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

Return Value

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

Remarks

Number.BitwiseShiftRight shifts the binary representation of number to the right by shift positions. It performs an arithmetic right shift: the high-order bits are filled with the sign bit of the original value (0 for positive numbers, 1 for negative numbers). This means shifting a non-negative integer right by n is equivalent to integer division by 2^n (truncating toward zero).

This is the complement of Number.BitwiseShiftLeft. Common uses include:

- Extracting packed bit fields: shift a packed integer right to bring the desired field to the low-order bits, then AND with a mask - Efficient powers-of-2 division: Number.BitwiseShiftRight(x, n) is a fast alternative to Number.IntegerDivide(x, Number.Power(2, n)) - Undoing a left shift: recover the original value that was shifted left

Note that for negative numbers, the sign-extension fill means right-shifting produces increasingly negative values (not unsigned logical shift). Power Query M uses arithmetic (signed) right shift for all Number.BitwiseShiftRight operations.

Examples

Example 1: Shift 16 right by 2 positions — equivalent to 16 ÷ 4

Result
Result
14

Example 2: Extract the upper nibble (bits 4–7) from a byte value

Result
Result
111

Example 3: Round-trip through shift left and shift right

let
    Original = 5,
    Shifted = Number.BitwiseShiftLeft(Original, 3),
    Restored = Number.BitwiseShiftRight(Shifted, 3)
in
    Restored
Applied Steps

The final output — the round-trip result, confirming the original value 5 is fully restored.

Result
15

Compatibility

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