0 of 60 lessons complete (0%)
Exit Course

# Extract values from records (Field Access)

This is a preview lesson

### Exercise file name:

2.2 Extract values from tables records and lists.pbix

### Content from the official Reference guide

The field-access-expression is used to select a value from a record or to project a record or table to one with fewer fields or columns, respectively.
The simplest form of field access is required field selection. It uses the operator x[y] to look up a field in a record by field name. If the field y does not exist in x, an error is raised. The form x[y]? is used to perform optional field selection, and returns null if the requested field does not exist in the record.
For example:
``` [A=1,B=2][B] // 2 [A=1,B=2][C] // error [A=1,B=2][C]? // null ```
Collective access of multiple fields is supported by the operators for required record projection and optional record projection. The operator x[[y1],[y2],…] projects the record to a new record with fewer fields (selected by y1, y2, …). If a selected field does not exist, an error is raised. The operator x[[y1],[y2],…] projects the record to a new record with the fields selected by y1, y2, …; if a field is missing, null is used instead.
For example:
``` [A=1,B=2][[B]] // [B=2] [A=1,B=2][[C]] // error [A=1,B=2][[B],[C]]? // [B=2,C=null] ```