Expression.Evaluate
Returns the result of evaluating an M expression.
Syntax
Expression.Evaluate(
document as text,
optional environment as record
) as any
Remarks
Returns the result of evaluating an M expression document
, with the available identifiers that can be referenced defined by environment
.
Examples
Example #1
Evaluate a simple sum.
Expression.Evaluate("1 + 1")
Result:
2
Example #2
Evaluate a more complex sum.
Expression.Evaluate("List.Sum({1, 2, 3})", [List.Sum = List.Sum])
Result:
6
Example #3
Evaluate the concatenation of a text value with an identifier.
Expression.Evaluate(Expression.Constant("""abc") & " & " & Expression.Identifier("x"), [x = "def"""])
Result:
"""abcdef"""
Category
Expression