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

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

## What it does
Record.RemoveFields returns a copy of a record with the named fields taken out. Use it to drop helper fields, personal data you do not need in the report, or columns that are empty in the source. It is the record version of removing columns from a table.

## Syntax and arguments
- `record`: the record to change.
- `fields`: the field name, or a list of field names, to remove.
- `missingField` (optional): what to do if a named field is not there. The default is to raise an error. `MissingField.Ignore` skips the missing names quietly.

## Example
A payroll-style record includes a national identifier that should not go into a shared report. The fields needed for the report are kept and the sensitive one is removed.

```powerquery
let
    Employee = [Name = "Ann Lee", Department = "Finance", TaxId = "XXX-XX-1234", Hours = 160],
    ReportRow = Record.RemoveFields(Employee, {"TaxId"}),
    Names = Record.FieldNames(ReportRow)
in
    ReportRow
```

`ReportRow` has Name, Department and Hours. The tax identifier is gone from the copy. The original record is unchanged.

## Example: a second, different use
Removing helper fields after a calculation: list the working fields in the second argument and remove them before the record goes to the report.

## Things to watch
- Removing a field that does not exist is an error, unless you pass `MissingField.Ignore`.
- Removing a field from a record does not delete the source data.
- Check that the report does not need a field you have removed. A total that depends on a removed field fails, which is usually the right outcome.
- To keep only the fields you want, Record.SelectFields is often clearer.

## In business terms
Removing confidential or unneeded fields before a file is shared is a control step. Keep the list of removed fields in the query, so a reviewer can see what was taken out and why.
