Value.Expression
ValueReturns an abstract syntax tree (AST) representation of the expression that produces the given value.
Syntax
Value.Expression(value as any) as anyParameters
| Name | Type | Required | Description |
|---|---|---|---|
value | any | Yes | The value whose expression representation is returned. |
Return Value
any — An AST record representing the expression that would produce the value.
Remarks
Value.Expression returns an abstract syntax tree (AST) representation of the M expression that would produce the given value. The AST is itself an M value — a record with fields describing the expression kind (e.g., "Constant", "List", "Record") and its children (sub-expressions).
This function is an advanced introspection tool used for metaprogramming — building query generators, expression analyzers, serializers, or code transformation utilities that treat M expressions as data. It is used internally by the Power Query Editor and by custom connector development tooling.
For the vast majority of data transformation work in Power Query, Value.Expression is not needed. It is relevant only when you are building tools that operate on M queries themselves rather than on data.
The structure of the returned AST record follows the M specification's expression grammar. For example:
- A numeric literal produces [Kind = "Constant", Value = 42]
- A list literal produces [Kind = "List", Items = { ... }] where each item is its own AST node
The AST can be passed to Expression.Evaluate (with an appropriate environment) to re-evaluate it, or processed with M record and list operations to inspect or transform the expression structure.
Examples
Example 2: AST of a list literal shows nested nodes
Value.Expression({1, 2, 3})Kind | Items | |
|---|---|---|
| 1 | List | [object Object],[object Object],[object Object] |