Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join now60 Days of Data Days! Live and on-demand sessions, challenges, study groups and more! And it's all FREE!. Join now. Learn more
Make M code adoption and debugging easy with record-expressions. In the M language, both let- and record-expressions are used to create more complex expressions. Let's review them.
A let-expression starts with a let-clause and contains a comma-separated list of variables and expressions assigned to them. Variables can refer to other variables, and whatever is returned after the in-clause that’s the result of the let-expression.
To illustrate, this let-expression returns the value 6.
A record-expression is a comma-separated list of fields, each field is a name/value pair. Fields can refer to other fields, and the result can be an entire record, a selection of fields, or a single field value.
To illustrate, this record-expression returns 6, like the let-expression above.
Both let- and record-expressions require variable/field names to be unique. A key difference is that most of the time record-expressions allow field names to be written without the quoted notation, which improves the readability of the code.
The flexibility of a record-expression is what makes it truly valuable for adoption, validation, troubleshooting, debugging, and reviewing M code since you can quickly change its return value, as illustrated here:
Illustrating the flexibility of a record-expression
The flexibility of record-expressions is what makes it valuable for adoption and troubleshooting. Key points to keep in mind:
Omit field selection: [b] 👉 to return the entire record.
Replace it with projection and selection: [[b], [c]] 👉 to return a record with selected fields.
https://learn.microsoft.com/en-us/powerquery-m/m-spec-let
https://learn.microsoft.com/en-us/powerquery-m/m-spec-values#record
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.