Dax Function: OR

Category: Logical Functions 

The OR function in Power BI is a logical DAX (Data Analysis Expressions) function used to evaluate multiple conditions. It returns TRUE if at least one of the conditions evaluates to TRUE; otherwise, it returns FALSE.

Purpose

  • To combine multiple logical tests into a single condition.
  • Simplifies decision-making logic when either of several conditions can result in TRUE.

Type of Calculations

  • Boolean logic-based calculations.
  • Frequently used in conditional columns, measures, and calculated tables.

Practical Use Cases

  • Checking if any one of multiple criteria is satisfied.
  • Filtering data where more than one condition can apply.
  • Creating calculated columns or measures with compound logic.
				
					OR(<logical1>, <logical2>)
				
			
ParameterTypeDescription
logical1ScalarThe first Boolean expression to evaluate.
logical2ScalarThe second Boolean expression to evaluate.

How Does OR Dax Function Works?

The OR function evaluates the provided logical expressions sequentially:

  1. If logical1 evaluates to TRUE, the function immediately returns TRUE without evaluating logical2.
  2. If logical1 is FALSE, it evaluates logical2 and returns its value (TRUE or FALSE).

Logical Principle

The function adheres to the standard OR truth table:

Logical1Logical2Output (OR)
TRUETRUETRUE
TRUEFALSETRUE
FALSETRUETRUE
FALSEFALSEFALSE

What Does It Return?

The OR function returns a Boolean value:

  • TRUE if at least one of the two logical expressions evaluates to TRUE.
  • FALSE if both logical expressions evaluate to FALSE.

When Should We Use It?

  • Compound Conditions: Use when combining multiple criteria where any condition being TRUE is sufficient.
  • Data Filtering: Apply in measures or calculated columns for flexible filtering.
  • Conditional Logic: Implement dynamic behavior based on multiple logical tests.

Examples

Basic Usage

Evaluate two simple conditions:

				
					Result = OR(1 > 0, 2 < 1)
				
			

Output: TRUE (because the first condition is TRUE).

Column Usage:

Create a calculated column to check if a sales record is either for a specific product or above a certain revenue threshold:

				
					High Priority = OR(Sales[Product] = "A", Sales[Revenue] > 1000)
				
			

Explanation: Returns TRUE for records where Product = "A" or Revenue > 1000.

Advanced Usage

Combine with other DAX functions:

				
					Complex Check = OR(AND(Sales[Region] = "East", Sales[Revenue] > 500), Sales[Product] = "B")
				
			

Explanation: Returns TRUE if:

  1. The region is “East” and revenue is greater than 500, or
  2. The product is “B”.

Tips and Tricks

  • Short-Circuit Evaluation: The function stops evaluating once a TRUE is found. Arrange conditions by likelihood for efficiency.
  • Use Alternatives for Multiple Conditions: For more than two conditions, use || or the OR operator in calculated columns and measures.
    • Example: Condition = (A || B || C)
  • Avoid Mixing Data Types: Ensure both inputs are Boolean to prevent unexpected results.
  • Combine with IF: Often paired with IF to create conditional logic.

Performance Impact of OR DAX Function:

  • Efficient for Two Conditions: For more than two, consider using alternative syntax (e.g., ||).
  • Short-Circuit Behavior: Improves performance by stopping evaluation when TRUE is found.

Related Functions You Might Need

  • AND: Returns TRUE if all conditions are true.
  • NOT: Negates a Boolean value.
  • IF: Creates conditional logic based on Boolean expressions.
  • || (OR Operator): Alternative to the OR function for multiple conditions.

Want to Learn More?
For more information, check out the official Microsoft documentation for OR. You can also experiment with this function in your Power BI reports to explore its capabilities.

Unlock the full capabilities of Power BI and elevate your data insights with our specialized consulting services. Whether you need guidance on advanced DAX functions like those highlighted here, support in designing interactive dashboards, or expertise in optimizing data models for enhanced performance, our experienced Power BI consultants are equipped to deliver customized solutions for your business. Explore our Power BI Consulting Services page to discover how we can help your organization make smarter, data-driven decisions.

1. What does the OR function do in Power BI?

The OR function evaluates two conditions and returns TRUE if at least one is TRUE, otherwise it returns FALSE.

2. Can OR handle more than two conditions?

No, the OR function in DAX only accepts two parameters. For more conditions, use || or nest multiple OR functions.

3. How is OR different from AND?

OR returns TRUE if any condition is true, while AND returns TRUE only if all conditions are true.

4. Can OR be used with columns in Power BI?

Yes, it can evaluate conditions on column values, often in calculated columns or measures.

5. Is there a performance advantage to using OR?

The function short-circuits, meaning it stops evaluating once a TRUE condition is found, improving performance in some cases.

Established in 2020, Lets Viz Technologies provides a full range of high-quality data analysis and data visualization services. We are also an authorized Zoho Partner.

 

Contact

WeWork Berger Delhi One, C-001/A2, Sector 16B, Noida, Uttar Pradesh 201301

0124-502-5592
info@lets-viz.com

We are Social

Trust Pilot Reviews