Daily DAX : Day 311 BITOR

Power BI DAX BITOR Function

Description

The BITOR function in Power BI DAX performs a bitwise OR operation on two integers. It compares each bit of the first number with the corresponding bit of the second number. If either bit is 1, the result for that bit is 1; otherwise, it is 0.

Syntax

BITOR(number1, number2)
  • number1: First integer for the bitwise OR operation.
  • number2: Second integer for the bitwise OR operation.

Return Value

An integer representing the result of the bitwise OR operation.

Use Case

The BITOR function is useful in scenarios involving bit manipulation, such as managing permissions, flags, or binary states in data models. For example, it can combine permission flags where each bit represents a specific permission.

Example

Suppose you have two permission flags:

  • Read Permission (binary: 001, decimal: 1)
  • Write Permission (binary: 010, decimal: 2)

To grant both permissions, use BITOR:

Result = BITOR(1, 2)

Calculation:

    001 (1 in decimal)
  | 010 (2 in decimal)
  -----------------
    011 (3 in decimal)
    

Output: 3 (representing both Read and Write permissions).

Practical Application

In a Power BI data model, you might use BITOR to combine user permissions stored as integers in a table. For example:

CombinedPermissions = BITOR(UserTable[Permission1], UserTable[Permission2])

This creates a new column with the combined permission flags, which can then be checked to determine access levels.

Notes

  • Both inputs must be integers; non-integer values are truncated.
  • Negative numbers are supported, following two's complement representation.
  • Useful in niche scenarios like system configuration or low-level data processing.

Comments

Popular posts from this blog

Daily DAX : Day 65 INFO.TABLEPERMISSIONS

Daily DAX : Day 55 PV