ItemExpression.From

Updated on

ItemExpression.From is a Power Query M function that returns the abstract syntax tree (AST) for the body of a 1-argument lambda function. The function returns an item expression AST or raises an error if the AST cannot be returned.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

ItemExpression.From( function as function ) as record

Description

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

  • The function must be a 1-argument lambda.
  • All references to the function parameter are replaced with ItemExpression.Item.
  • The AST will be simplified to contain only nodes of the kinds:
    • Constant
    • Invocation
    • Unary
    • Binary
    • If
    • FieldAccess

An error is raised if an item expression AST cannot be returned for the body of function.

Examples

Returns the AST for the body of the function each _ <> null

ItemExpression.From( each _ <> null )

 /* Output: 
[
    Kind = "Binary",
    Operator = "NotEquals",
    Left = ItemExpression.Item,
    Right =
    [
        Kind = "Constant",
        Value = null
    ]
]
 */ 

Other functions related to ItemExpression.From are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/itemexpression-from