Value.FromText

Value

Converts a text value to a typed value based on its content.

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

Syntax

Value.FromText(value as any, optional culture as nullable text) as any

Parameters

NameTypeRequiredDescription
valueanyYesThe text value to convert.
culturetextNoA culture code (e.g., "en-US") that influences how the text is parsed.

Return Value

anyA value interpreted from the text input. Numbers, dates, logicals, and other types are automatically detected.

Remarks

Value.FromText attempts to interpret a text string and convert it to the most appropriate typed value. It can detect numbers, dates, logicals, and other types from their text representation. An optional culture parameter controls locale-specific parsing rules for numbers and dates.

This function is useful when processing text-based data sources where all values arrive as text and need to be converted to their proper types.

Examples

Example 1: Parse various text values into typed values

let
    TextValues = {"42", "true", "3.14"},
    Parsed = List.Transform(TextValues, each Value.FromText(_)),
    TypeNames = List.Transform(Parsed, each
        if Value.Is(_, type number) then "number"
        else if Value.Is(_, type logical) then "logical"
        else "other"
    )
in
    #table(
        {"InputText", "ParsedValue", "DetectedType"},
        List.Zip({TextValues, List.Transform(Parsed, each Text.From(_)), TypeNames})
    )
Result
InputText
ParsedValue
DetectedType
14242number
2truetruelogical
33.143.14number

Compatibility

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