BITAND DAX Function (Logical)

Returns a bitwise ‘AND‘ of two numbers.

Syntax

BITAND ( <Number1>, <Number2> )
Parameter Attributes Description
Number1

The first number.

Number2

The second number.

Return values

Scalar A single integer value.

A bitwise AND of two numbers.

Remarks

If an argument has decimal places, BITAND rounds it to the nearest integer. A value that is exactly halfway is rounded away from zero. For example, 2.5 becomes 3 and -2.5 becomes -3.

BITAND supports negative numbers. It uses the 64-bit two’s complement form of each number.

If one or both arguments are BLANK, BITAND returns BLANK.

A text argument that can be converted to a number is converted. If an argument cannot be converted to a 64-bit integer, BITAND returns an error.

Examples

DEFINE
    VAR ValA = SELECTCOLUMNS ( GENERATESERIES ( -5, 5 ), "A", [Value] )
    VAR ValB = SELECTCOLUMNS ( GENERATESERIES ( -5, 5 ), "B", [Value] )
EVALUATE
    ADDCOLUMNS (
        CROSSJOIN ( ValA, ValB ),
        "BITAND", BITAND ( [A], [B] ),
        "BITOR", BITOR ( [A], [B] ),
        "BITXOR", BITXOR ( [A], [B] )
    )
ORDER BY [A] DESC, [B] DESC
A B BITAND BITOR BITXOR
5 5 5 5 0
5 4 4 5 1
5 3 1 7 6
5 2 0 7 7
5 1 1 5 4
5 0 0 5 5
5 -1 5 -1 -6
5 -2 4 -1 -5
5 -3 5 -3 -8
5 -4 4 -3 -7
5 -5 1 -1 -2
4 5 4 5 1
4 4 4 4 0
4 3 0 7 7
4 2 0 6 6
4 1 0 5 5
4 0 0 4 4
4 -1 4 -1 -5
4 -2 4 -2 -6
4 -3 4 -3 -7
4 -4 4 -4