Value.Expression

Value

Returns an abstract syntax tree (AST) representation of the expression that produces the given value.

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

Syntax

Value.Expression(value as any) as any

Parameters

NameTypeRequiredDescription
valueanyYesThe value whose expression representation is returned.

Return Value

anyAn 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 1: AST of a numeric literal

Result
Kind
Value
1Constant42

Example 2: AST of a list literal shows nested nodes

Value.Expression({1, 2, 3})
Result
Kind
Items
1List[object Object],[object Object],[object Object]

Example 3: Inspect the Kind field of the AST

Value.Expression({1, 2, 3})[Kind]
Result
Result
1List

Compatibility

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