Variable.Value

Value

Returns the value of a variable identified by name from the current evaluation environment.

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

Syntax

Variable.Value(identifier as text) as any

Parameters

NameTypeRequiredDescription
identifiertextYesThe name of the variable to look up in the current evaluation environment.

Return Value

anyThe value of the specified variable in the current evaluation environment.

Remarks

Variable.Value retrieves the value of a variable by its text name from the current evaluation environment. If the variable identified by identifier is not defined in the environment, an error is raised.

This is an internal engine function used by the Power Query evaluation infrastructure to resolve variable references dynamically at runtime. It is part of the mechanism by which the M engine looks up names during expression evaluation.

In normal user-written M queries, variable references are resolved directly by the language (e.g., writing myVar in a let expression). Variable.Value exists to support scenarios where variable resolution must happen programmatically — such as within the engine's own evaluation pipeline, custom connector internals, or advanced metaprogramming utilities that manipulate expressions as data.

Calling Variable.Value directly in a standard query is not recommended. If you need dynamic name resolution, consider Expression.Evaluate with an explicit environment record or Record.Field to look up fields by name.

Examples

Example 1: Conceptual usage — resolve a variable by name

let
    x = 10,
    // Conceptually equivalent to accessing x by name:
    // Variable.Value("x") would return 10 within the engine
    Result = x
in
    Result
Output
Result
110

Compatibility

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