Variable.Value
ValueReturns the value of a variable identified by name from the current evaluation environment.
Syntax
Variable.Value(identifier as text) as anyParameters
| Name | Type | Required | Description |
|---|---|---|---|
identifier | text | Yes | The name of the variable to look up in the current evaluation environment. |
Return Value
any — The 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
ResultResult | |
|---|---|
| 1 | 10 |