Expression.Evaluate

This function evaluates an M expression document and returns the result. It takes into account the available identifiers that are defined in the environment and can be referenced within the document.

Syntax

Expression.Evaluate(document as text, optional environment as nullable record) as any

About

This function evaluates an M expression document and returns the result. It takes into account the available identifiers that are defined in the environment and can be referenced within the document.

Explanation

Example 1 Assess a basic addition calculation. Usage Power Query MExpression.Evaluate("1 + 1") Output 2 Example 2 Assess a more intricate addition calculation. Usage Power Query MExpression.Evaluate("List.Sum({1, 2, 3})", [List.Sum = List.Sum]) Output 6 Example 3 Assess the merging of a text value with an identifier. Usage Power Query MExpression.Evaluate(Expression.Constant("""abc") & " & " & Expression.Identifier("x"), [x = "def"""]) Output """abcdef"""