ItemExpression.From

Expression

Returns the abstract syntax tree (AST) for the body of a function, normalized into an item expression.

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

Syntax

ItemExpression.From(function as function) as record

Parameters

NameTypeRequiredDescription
functionfunctionYesA single-argument lambda function whose body will be converted to an AST.

Return Value

recordA record representing the abstract syntax tree (AST) of the function body as an item expression.

Remarks

ItemExpression.From returns the abstract syntax tree (AST) for the body of function, normalized into an *item expression*. This is an advanced/internal function used by the Power Query engine and custom connector infrastructure, particularly for query folding.

### Requirements

  • The function must be a single-argument lambda (e.g., an each expression).
  • All references to the function parameter are replaced with ItemExpression.Item.
  • The AST is simplified to contain only these node kinds: Constant, Invocation, Unary, Binary, If, and FieldAccess.

An error is raised if the function body cannot be represented as a valid item expression AST.

This function is identical to RowExpression.From. The difference is semantic: ItemExpression.From is used in list contexts (where the parameter represents a list item), while RowExpression.From is used in table contexts (where the parameter represents a row).

### Use cases

  • Custom connectors that need to inspect filter or transformation expressions for query folding.
  • Building expression trees that can be translated to native query languages (SQL, OData, etc.).

Examples

Example 1: Get the AST for a null check

let
    AST = ItemExpression.From(each _ <> null)
in
    #table(
        {"Kind", "Operator"},
        {{AST[Kind], AST[Operator]}}
    )
Output
Kind
Operator
1BinaryNotEquals

Compatibility

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