Logical.FromText

Logical

Converts a text 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.FromText(text as text) as nullable logical

Parameters

NameTypeRequiredDescription
texttextYesA text value to convert. Must be "true" or "false" (case-insensitive).

Return Value

logicalA logical value parsed from the text input.

Remarks

Logical.FromText converts the text strings "true" and "false" (case-insensitive) to their corresponding logical values. Any other text input raises an error. This is useful when importing data from text-based sources where boolean values are stored as strings.

Examples

Example 1: Parse text boolean values

let
    Values = {"true", "false", "TRUE", "False"},
    Results = List.Transform(Values, each Logical.FromText(_)),
    TextResults = List.Transform(Results, each Text.From(_))
in
    #table(
        {"InputText", "AsLogical"},
        List.Zip({Values, TextResults})
    )
Result
InputText
AsLogical
1truetrue
2falsefalse
3TRUEtrue
4Falsefalse

Compatibility

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