M Language Online Course: The unofficial and Practical Reference Guide

Let Expression

This is a preview lesson

Purchase this course, or sign in if you’re already enrolled, to take this lesson.

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?
0 of 62 lessons complete (0%)