RemoveFields function

Applies To
Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web

Use .RemoveFields() to get a copy of a value without some of its fields. For example, drop an employee's Location field before you pass the entity to another formula.

.RemoveFields() is a dot function: you call it on a value by typing a period after the value. It returns a new value and leaves the original unchanged. For an overview, see Data types and dot functions in Excel.

Note

These features are rolling out to Microsoft 365 Insiders in Beta Channel on Windows Version 2612 (Build 20715.20000) or later and Mac Version 16.117 (Build 26111815) or later, and in Excel for the web.

Syntax

.RemoveFields() returns a copy of value without the fields you name.

value.RemoveFields(field_name, [field_name], ...)

Argument Description
value (required) The value before the dot: an entity (including a Linked Data Type such as Stocks), or a number, text, or Boolean that has fields. Can be a cell reference, a formula, or an array of values.
field_name (required) The name of a field to remove, as text, or an array of names.
field_name (optional) More names to remove.

Notes

  • The display text and the fields you don't name stay as they are.
  • Field names aren't case-sensitive.
  • .RemoveFields() ignores a name that the value doesn't have, instead of returning an error.
  • Removing every field from a number, text, or Boolean returns its basic value.
  • Removing every field from an entity returns an entity that still shows its display text but has no fields.
  • When value is an array, .RemoveFields() removes the fields from each item. For example, =Employees[#Entities].RemoveFields("Full name") removes that field from every row.
  • Removing a field isn't a way to hide data, because .RemoveFields() doesn't change the original. Anyone with the workbook can still read the field from the original cell or table.
  • To check for a field first, use .HasField().

Examples

Copy the example data and paste it in cell A1 of a new Excel worksheet. If you need to, you can adjust the column widths to see all the data.

Example 1

Remove one field and keep the original.

Field Value
Name Ada
Team Design
Location London
Formula Result
=ENTITY(B2,A2:A4,B2:B4) Ada
=A6.RemoveFields("Location") Ada
=A7.HasField("Location") FALSE
=A6.HasField("Location") TRUE

A6 uses the ENTITY function to build an employee entity: a value that shows Ada in its cell and holds Name, Team, and Location fields.

The original Ada entity with a Location field, and a copy without one

Example 2

Remove several fields with an array of names. Continuing from Example 1, enter these formulas in A10 and A11:

Formula Result
=A6.RemoveFields({"Team","Location"}) Ada
=A10.GetFieldNames() Name

Example 3

Remove every field from a number.

Label Value
Training hours 12.5
Formula Result
=B2.SetFields("Source","HR system", "Year",2026) 12.5, with Source and Year fields
=A4.RemoveFields(A4.GetFieldNames()) 12.5, with no fields

Errors

.RemoveFields() doesn't return an error for a field name the value doesn't have, or for a value with no fields.

See also