Logical.From
LogicalConverts a value to a logical (true/false).
Syntax
Logical.From(value as any) as nullable logicalParameters
| Name | Type | Required | Description |
|---|---|---|---|
value | any | Yes | The value to convert to a logical. Numbers: 0 is false, non-zero is true. Text: "true"/"false" are converted. Logical values are returned as-is. |
Return Value
logical — A logical value derived from the input. 0 becomes false, any other number becomes true.
Remarks
Logical.From converts a value to a logical (true or false). The conversion rules are:
- Numbers: 0 converts to false, any non-zero number converts to true.
- Text: "true" and "false" (case-insensitive) are converted to their logical equivalents.
- Logical: Returned unchanged.
- null: Returns null.
An error is raised if the value cannot be converted (e.g., non-boolean text like "hello").
Examples
Example 1: Convert quantities to logical flags
let
Values = {0, 1, 4, -1},
Results = List.Transform(Values, each Logical.From(_)),
TextResults = List.Transform(Results, each Text.From(_))
in
#table(
{"InputValue", "AsLogical"},
List.Zip({List.Transform(Values, each Text.From(_)), TextResults})
)Result
InputValue | AsLogical | |
|---|---|---|
| 1 | 0 | false |
| 2 | 1 | true |
| 3 | 4 | true |
| 4 | -1 | true |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks