Use .GetFieldNames() to list the names of a value's fields. For example, see what an entity holds before you write formulas that read it.
.GetFieldNames() 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
.GetFieldNames() returns a vertical array of field names.
value.GetFieldNames()
| 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. |
Notes
- Names come back in alphabetical order, not in the order the fields were added.
- .GetFieldValues() with no arguments returns values in the same order, so you can pass both to .SetFields() to copy fields onto another value. For example, if A2 is a number with fields, =A2+1 drops them, but =(A2+1).SetFields(A2.GetFieldNames(),A2.GetFieldValues()) keeps them.
- A field that holds another entity is listed once, by its own name.
- To count fields, wrap .GetFieldNames() in ROWS: =ROWS(A6.GetFieldNames()).
- To act on every field, pass the names to MAP or REDUCE. For example, =MAP(A6.GetFieldNames(),LAMBDA(n,n&": "&A6.GetFieldValues(n))) returns Location: London, Name: Ada, Team: Design.
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 and count the fields.
| Field | Value |
|---|---|
| Name | Ada |
| Team | Design |
| Location | London |
| Formula | Result |
| =ENTITY(B2,A2:A4,B2:B4) | Ada |
| =ROWS(A6.GetFieldNames()) | 3 |
| =A6.GetFieldNames() | Location, Name, Team (spills into A8:A10) |
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.
Example 2
List the fields of an entity that holds another entity. Continuing from Example 1, enter these formulas in C7 and C8:
| Formula | Result |
|---|---|
| =ENTITY("Design team", "Lead",A6, "Size",5) | Design team |
| =C7.GetFieldNames() | Lead, Size (spills into C8:C9) |
Errors
| Error | Cause |
|---|---|
| #FIELD! | value has no fields, such as an entity whose fields were all removed. |
| #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. |