Daily DAX : Day 450 ISBOOLEAN
Power BI DAX Function: ISBOOLEAN
Description
The ISBOOLEAN function checks whether a given value is a Boolean (logical) value, meaning it is either TRUE or FALSE. It returns TRUE if the value is Boolean, and FALSE otherwise.
Note: ISBOOLEAN is an alias for ISLOGICAL and belongs to the Information functions category in DAX.
Syntax
ISBOOLEAN(<value>)
Parameters
- value: The value or expression to check. This can be a constant, column reference, or any DAX expression.
Return Value
A Boolean value: TRUE or FALSE.
Examples
ISBOOLEAN(TRUE) // Returns TRUE
ISBOOLEAN(FALSE) // Returns TRUE
ISBOOLEAN(1) // Returns FALSE (1 is treated as numeric, not Boolean in type checking)
ISBOOLEAN("True") // Returns FALSE (text string)
ISBOOLEAN(BLANK()) // Returns FALSE
Another example in a query:
IF ( ISBOOLEAN(TRUE), "It is Boolean", "Not Boolean" )
// Returns "It is Boolean"
Use Cases
ISBOOLEAN is particularly useful for:
- Type validation: Ensuring that a parameter or column value is truly Boolean before performing logical operations, especially in complex measures or custom functions.
- Dynamic calculations: In scenarios where expressions might return different data types (e.g., due to errors or blanks), to safely handle Boolean-specific logic.
- Debugging and error handling: Checking input types in calculated columns or measures to prevent unexpected behavior.
- Advanced scenarios: With user-defined functions (UDFs) or when integrating data from varied sources where type consistency needs verification.
It helps make DAX code more robust by explicitly verifying data types.
Comments
Post a Comment