Downloads
Power Query MRecordIntermediate

Record.RemoveFields

Returns a copy of a record without the fields you name.

Syntax
Record.RemoveFields(record, fields, optional missingField)

Returns: A new record with the named fields removed.

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

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.

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

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.

Related functions

All Power Query M functions · View as Markdown · M basics