M Language Online Course: The unofficial and Practical Reference Guide [updated 2025]

Let Expression

This is a preview lesson

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

Exercise files

You can download my demo files here, but I recommend you to type everything yourself.

About Let Expression

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?