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(, )
Parameter | Type | Description |
---|---|---|
logical1 | Scalar | The first Boolean expression to evaluate. |
logical2 | Scalar | The second Boolean expression to evaluate. |
How Does OR Dax Function Works?
The OR function evaluates the provided logical expressions sequentially:
- If
logical1
evaluates toTRUE
, the function immediately returnsTRUE
without evaluatinglogical2
. - If
logical1
isFALSE
, it evaluateslogical2
and returns its value (TRUE
orFALSE
).
Logical Principle
The function adheres to the standard OR truth table:
Logical1 | Logical2 | Output (OR) |
---|---|---|
TRUE | TRUE | TRUE |
TRUE | FALSE | TRUE |
FALSE | TRUE | TRUE |
FALSE | FALSE | FALSE |
What Does It Return?
The OR function returns a Boolean value:
TRUE
if at least one of the two logical expressions evaluates toTRUE
.FALSE
if both logical expressions evaluate toFALSE
.
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:
- The region is “East” and revenue is greater than 500, or
- 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)
- Example:
- 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.
The OR function evaluates two conditions and returns TRUE
if at least one is TRUE
, otherwise it returns FALSE
.
No, the OR function in DAX only accepts two parameters. For more conditions, use ||
or nest multiple OR functions.
OR returns TRUE
if any condition is true, while AND returns TRUE
only if all conditions are true.
Yes, it can evaluate conditions on column values, often in calculated columns or measures.
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.
Sitelinks