<!-- https://learnsql.cpetoday.com/functions/m/record-selectfields -->
# Record.SelectFields

Language: Power Query M
Category: Record
Syntax: Record.SelectFields(record, fields, optional missingField)
Summary: Returns a copy of a record that keeps only the fields you name.
Returns: A new record with only the chosen fields.
Level: Intermediate
Related: Record.RemoveFields, Record.RenameFields, Record.FieldNames, Record.HasFields, Record.AddField

## What it does
Record.SelectFields keeps only the fields you list and drops the rest. It is the opposite of Record.RemoveFields. Use it when a row has many fields and you want a fixed, known set in a fixed order, for example to build the standard line for a journal template.

## Syntax and arguments
- `record`: the record to filter.
- `fields`: the list of field names to keep.
- `missingField` (optional): what to do if one of the named fields is missing. The default is an error. `MissingField.UseNull` puts a null in its place, which helps when some exports lack an optional column.

## Example
A bank export has many columns. The journal template needs only the date, the amount and the description, and some exports do not carry a reference column.

```powerquery
let
    BankRow = [Date = #date(2026, 3, 31), Amount = 1250, Description = "Rent", Reference = null, Branch = "Reno"],
    JournalLine = Record.SelectFields(BankRow, {"Date", "Amount", "Description"})
in
    JournalLine
```

`JournalLine` has three fields only: Date, Amount and Description. Branch and Reference are dropped. Using `MissingField.UseNull` would keep the layout stable if a row lacked one of the three fields.

## Example: a second, different use
Keeping a stable set of columns from a file whose layout changes: list the columns you need, and use `MissingField.UseNull` so a missing column becomes an empty column rather than a failure.

## Things to watch
- The order of the names in the list does not set the order of the fields in the result. Use Table.ReorderColumns on a table when the column order matters.
- The default makes a missing field an error, which is usually the safer result for a required column.
- If you only want to drop a few fields, Record.RemoveFields is shorter.
- Check the field names exactly. "Amount" and "amount" are different fields.

## In business terms
Mapping an export to a standard layout, such as a journal import template or a standard chart of accounts line, is a classic use. Named columns make the mapping visible to the reviewer.
