Lookup

A Lookup field brings field values from a related table into the current table. Use it to show more information about a record in a table. For example, you have an Orders table and a Customers table. Use a Lookup field to show the name and address of the customer in the Orders table.

Ask NocoAI

Copy a prompt, paste it into NocoAI in any base, and replace the words in [brackets] with your own.

  • Show each [customer]'s [Email] on the [Orders] table
  • Add a lookup of [Project Owner] to [Tasks]
  • Bring [Category] from the linked [Products] into this table

Create a Lookup Field

  1. Click the + icon to the right of the Fields header.
  2. In the dropdown modal, enter the field name (optional).
  3. In the dropdown, select the field type Lookup.
  4. In the dropdown, select the link field. This field links the current table to the related table.
  5. In the dropdown, select the field to show. The current table shows this field.
  6. Click the Save Field button.

image

Formatting

The Lookup field editor has two tabs:

  • Configuration: select the relation (link field) and the lookup field, as described above.
  • Formatting: set how the Lookup shows the looked-up value. This tab is disabled until you select a lookup field.

Use the Formatting tab to give the Lookup value a format that is independent of the source field. The format applies everywhere the Lookup shows, including the grid, the expanded record and exports.

The options depend on the type of the lookup result:

Result typeFormat options
numberThe Format selector shows Decimal, Currency or Percent.
DateOnly Date formatting.
DateTimeThe Format selector shows Date, DateTime or Time.
TimeOnly Time formatting.

When you select a format, NocoDB shows the usual sub-options of that format type (for example, precision for Decimal, or the date format for Date).

If the looked-up value is not a number, date, datetime or time value, formatting options are not available. You cannot format Duration results.

Lookup field Formatting tab

Conditional Lookup ☁

Conditional Lookup is available on NocoDB Cloud (Plus plan and above) and licensed self-hosted deployments (Business plan and above).

By default, a Lookup field shows all linked records from the related table. But you may want to show only some of those records. For example, only recent entries or records above a threshold.

To do this, turn on the option: Only include linked records that meet specific conditions

This option filters the linked records with conditions on fields in the related table. The Lookup field then shows only the data that is most relevant to your use case.

Applying filters

  1. Turn on Only include linked records that meet specific conditions.
  2. Click Add filter. Define one or more conditions with fields from the related table.
  3. To combine filters with AND/OR logic, use Add filter group.
  4. Click Save Field. NocoDB applies the filters.

Sort and limit lookup values ☁

Sort and limit for Lookup values is available on NocoDB Cloud (Plus plan and above) and licensed self-hosted deployments (Business plan and above). It is supported only on projects stored in PostgreSQL (including NocoDB Cloud). The options are not shown for lookups on other databases.

By default, a Lookup field shows every linked value in the link order. In the Lookup field editor, you can set the order of the looked-up values and the number of values that it shows.

Sort the looked-up values

  1. Open the Lookup field editor.
  2. Select the link field and the lookup field.
  3. Under Sort records, click Add Sort Option.
  4. Select the field to sort by and the direction.
  5. To break ties, add more sort options.
  6. Click Save Field.

Limit the number of values shown

  1. Turn on Limit the number of items shown.
  2. Under Limit to the, select First or Last in the dropdown.
  3. Enter the number of values to keep (minimum 1).
  4. Click Save Field.

Use a limit with a sort to show, for example, only the First three linked records by date. Existing Lookup fields do not change until you configure a sort or limit on them.

Good to know

  • Lookup fields are read-only. You cannot edit the values in a lookup field.

Last updated on

Latest product updates?See Changelog
Stay in the loop? Follow us onLinkedInLinkedInYouTubeYouTubeXX