Lists records and tables
Choose a value structure
M supports scalar values, including number, text, logical, null, dates and durations, and composite values such as lists, records and tables. A list is an ordered collection; a record holds uniquely named fields; a table holds rows under named columns. {} is an empty list and [] is an empty record. A text literal uses double quotes; embedded double quotes are doubled. true and false are logical literals; null denotes absence, not a blank text or numeric zero. #date(2026, 1, 5) constructs a date. All examples are complete standalone expressions for a blank Power Query query in a disposable Desktop file unless marked otherwise. No account, connector, file or network is required. Expected results are derived, not observed; native M execution and exact Desktop build are NOT RUN.
Select a list item and record field
let Quantities = {2, 5, 1}, Order = [ID = "L01", Quantity = Quantities{1}, Price = 4]in [ID = Order[ID], Amount = Order[Quantity] * Order[Price]]Expected record: ID = L01, Amount = 20. List positions are zero-based, so {1} picks 5. Record fields are accessed by name. A missing required field or an out-of-range index raises an error; optional access Order[Discount]? or Quantities{8}? returns null for a missing field or out-of-range positive index.
Construct a typed table
let Lines = #table(type table [ID = text, Qty = number], {{"L01", 2}, {"L02", 5}, {"L03", 1}})in LinesExpected table:
| ID | Qty |
|---|---|
| L01 | 2 |
| L02 | 5 |
| L03 | 1 |
The outer list supplies rows and each inner list supplies cells in declared column order. Lines{1}[Qty] selects 5; Lines[Qty] produces the column as a list. Row position is useful for this fixed fixture, not a stable business identity for an external data source.
Do not confuse shape with type conversion
[ID = "007"] preserves a text key, whereas [ID = 7] contains a number. In M, = compares values in an expression and binds names in a binding or field declaration; <> means not equal. & combines compatible values, for example "L" & "01" returns L01. A typed table constructor defines a schema; do not treat it as a general-purpose text parser. Use explicit conversion when reading text from a source.
Practice structured selection
Build a table with ID and Qty for A=4, B=0, C=7. Predict Rows{2}[ID], Rows[Qty], and the result of [Item = "A"][Missing]?. Explain which result is a list, a scalar or null.