Logical.From

Logical

Converts a value to a logical (true/false).

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Logical.From(value as any) as nullable logical

Parameters

NameTypeRequiredDescription
valueanyYesThe 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

logicalA 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
10false
21true
34true
4-1true

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks