Let Expression

Free Preview

Exercise file name:

4 M expressions.pbix

Content from the official Reference guide

The let expression allows a set of values to be computed, assigned names, and then used in a subsequent expression that follows the in. For example, in our sales data example, we could do:

let
Sales2007 =
[
Year = 2007,
FirstHalf = 1000,
SecondHalf = 1100,
Total = FirstHalf + SecondHalf // 2100
],
Sales2008 =
[
Year = 2008,
FirstHalf = 1200,
SecondHalf = 1300,
Total = FirstHalf + SecondHalf // 2500
]
in Sales2007[Total] + Sales2008[Total] // 4600

The result of the above expression is a number value (4600) which was computed from the values bound to the names Sales2007 and Sales2008.

Was this helpful?
[Total: 2    Average: 5/5]
Lesson tags: M language, Power Query
Back to: M Language Online Course: The unofficial and Practical Reference Guide > M Expressions

Let us know your thoughts...