GetFields function

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

Use .GetFields() to list a value's fields and values. For example, see every field of an employee entity in two columns.

.GetFields() is a dot function: you call it on a value by typing a period after the value. 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

.GetFields() returns a two-column array: field names on the left and their values on the right.

value.GetFields([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 or a formula.
field_name (optional) The name of a field to return. List more names to return more fields. If you omit it, .GetFields() returns every field.

Notes

  • The result spills down, one row per field. Leave the cells below and to the right empty.
  • With no names, fields come back in alphabetical order. With names, they come back in the order you list them, and the name column shows each name as you typed it.
  • Field names aren't case-sensitive.
  • A field that holds an entity shows that entity's display text.
  • For names only, use .GetFieldNames(). For values only, use .GetFieldValues().

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

List every field.

Field Value
Name Ada
Team Design
Location London
Formula Result
=ENTITY(B2,A2:A4,B2:B4) Ada

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.

Then enter this formula in D2:

Formula Result
=A6.GetFields() Location and London, Name and Ada, Team and Design, one pair per row (spills into D2:E4)

Field names and values spilled in three rows beside the employee data

Example 2

List the fields you name, in the order you name them. Continuing from Example 1, enter this formula in D7:

Formula Result
=A6.GetFields("Team","Name") Team and Design, Name and Ada, one pair per row (spills into D7:E8)

Example 3

List the fields on a number.

Label Value
Training hours 12.5
Formula Result
=B2.SetFields("Source","HR system", "Year",2026) 12.5

Then enter this formula in D2:

Formula Result
=A4.GetFields() Source and HR system, Year and 2026, one pair per row (spills into D2:E3)

Errors

Error Cause
#FIELD! A name you list isn't a field of value, or value is an entity with no fields.
#VALUE! value is a number, text, or Boolean with no fields. To skip such values, wrap the formula in IFERROR.
#SPILL! The cells the result spills into aren't empty.

See also