OpenBI Docs Buy

BITAND

Bit by bit AND of two whole numbers: a bit is set where both have it.

Group: Math. Compatible with DAX.

Syntax

BITAND ( <number1>, <number2> )
ParameterTypeDescription
number1Whole numberThe first whole number.
number2Whole numberThe second whole number.

Returns

Whole number. A number with only the bits that both numbers have set.

Remarks

  • 12 is 1100 in binary and 10 is 1010; the bits they share make 1000, which is 8.
  • Numbers with decimals are rounded to whole numbers first, a half away from zero. Negative numbers take part in 64-bit two's complement. BITAND ( -1, 255 ) is 255.
  • When either number is blank, the result is BLANK.
  • It tests flags kept together in one number: BITAND ( [Flags], 4 ) <> 0 is TRUE when the flag worth 4 is on.

Examples

Shared bits

EVALUATE
ROW (
    "12 and 10", BITAND ( 12, 10 ),
    "Flag 4 in 13", BITAND ( 13, 4 ) <> 0,
    "Flag 4 in 9", BITAND ( 9, 4 ) <> 0,
    "With a blank", BITAND ( BLANK (), 3 )
)
12 and 10Flag 4 in 13Flag 4 in 9With a blank
8TRUEFALSE(blank)

BITOR, BITXOR, BITLSHIFT, BITRSHIFT.

Last updated · OpenBI Studio 0.3.74