ENTITY function

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

Use the ENTITY function to keep related information together in one cell: display text that shows in the cell, plus named fields behind it. For example, keep a product's name, price, and supplier in one cell, and then read the price with =A2.Price.

An entity works like the Stocks and Geography data types: the cell shows its display text, and its card shows the fields. ENTITY lets you build one from your own data. 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

The ENTITY function returns an entity with the display text and fields you specify.

ENTITY(text, field_names, field_values, [field_names, field_values], ...)

Argument Description
text (required) The display text to show in the cell.
field_names (required) The name of a field, as text, or an array or range of names.
field_values (required) The value of the field. If field_names is an array or range, use an array or range of values with the same shape.
field_names, field_values (optional) More pairs of names and values, up to 126 pairs.

Notes

  • A field can hold a number, text, a Boolean, an array, an image, or another entity.
  • When a field comes from a cell that holds a formatted number, it becomes a formatted number value with the cell's format. A price shows as currency, and a date shows as a date, not a number.
  • Field names can be up to 255 characters long. They aren't case-sensitive, so =A2.team reads the Team field. A number used as a field name becomes text: 5 becomes the name "5".
  • If the same field name appears more than once, ENTITY uses the last value.
  • A field stores a value, not a formula. Because ENTITY is a formula, the entity updates when the values in the cells it references change.
  • A field value that comes from an empty cell stays empty: ISBLANK returns TRUE for it. Like a reference to an empty cell, it shows 0 when a formula returns it to the grid.
  • .GetFieldNames(), .GetFieldValues(), and .GetFields() list all fields in alphabetical order, whatever order you passed them in.
  • To read a field, type a period after the reference: =A2.Team. If the name contains a space, use brackets: =A2.[Start date].
  • To change an entity, use dot functions such as .SetFields() and .RemoveFields(). They return a new entity and leave the original unchanged.
  • To make one entity for each row of a table, use the #Entities special item specifier instead, as in =Employees[#Entities]. See Using structured references with Excel tables.

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

Create an entity from pairs of names and values. A field can hold an array.

Formula Result
=ENTITY("Dog", "Name","Bailey", "Age",3, "Favorite treats",{"Biscuits","Pig ears","Frozen bones"}) Dog
=A2.Name Bailey
=A2.Age 3

A2 shows Dog. Its card shows all three fields.

The Dog entity in A2 with its card open, showing Name, Age, and Favorite treats

Example 2

Create an entity from a range of names and a range of values.

Field Value
Name Ada
Team Design
Location London
Formula Result
=ENTITY(B2,A2:A4,B2:B4) Ada
=A6.Team Design
=A6.GetFieldNames() Location, Name, Team (spills into A8:A10)

The names in A2:A4 and the values in B2:B4 have the same shape, so each name pairs with the value beside it.

An employee entity built from two ranges, with its fields read back below it

Example 3

Put one entity inside another. Continuing from Example 2, enter these formulas in A11 and A12:

Formula Result
=ENTITY("Design team", "Lead",A6, "Size",5) Design team
=A11.Lead.Location London

The Lead field holds the whole employee entity, so =A11.Lead.Location follows the path from the team to the lead to her location.

Example 4

Keep a cell's number format.

Field Value
Item Tortillas
Price per kg $3.20
Formula Result
=ENTITY(B2,A2:A3,B2:B3) Tortillas
=A5.[Price per kg] $3.20, even in a cell formatted as General
=A5.[Price per kg]*2 6.4. Arithmetic uses the number; the result doesn't keep the format.

B3 holds the number 3.2 formatted as currency. If you change a referenced cell's format after you enter the formula, use Ctrl+Alt+F9 to update the entity.

If you don't use dollars, type the price in B3 with your own currency symbol.

Errors

If a field name has no value after it, Excel doesn't accept the formula.

Error Cause
#VALUE! field_names and field_values are ranges or arrays of different shapes.
#VALUE! A field name is empty or longer than 255 characters.
#VALUE! A formula joins text to the entity, as in ="Lead: "&A6. Join a field instead, as in ="Lead: "&A6.Name, or the display text, as in ="Lead: "&VALUETOTEXT(A6).
#FIELD! A formula reads a field that doesn't exist, as in =A2.Colour when the field is Color. Check first with .HasField(), or wrap the formula in IFERROR.

See also