> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://help.sigmacomputing.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://help.sigmacomputing.com/_mcp/server.

# Lookup

> Use the Sigma Lookup function to find matching data inside a data element, either in the same table, or in an external table.

The **Lookup** function finds matching data inside a workbook data element, either in the same table, or in an external table.

To understand how to apply the Lookup function without directly using the formula bar, see [Add columns through Lookup](/docs/add-columns-through-lookup).

All elements must be on the same data connection.

## Syntax

```
Lookup(formula, local key 1, external key 1, [local key 2], [external key 2], ...)
```

This function has the following arguments:

<dl>
  <dt>
    formula
  </dt>

  <dd>
    Required
  </dd>

  <dd>
    The formula to compute (or the target column to reference) for the row in the target element.
  </dd>

  <dt>
    local key 1
  </dt>

  <dd>
    Required
  </dd>

  <dd>
    The column to use as a join key in the local data element.
  </dd>

  <dt>
    external key 1
  </dt>

  <dd>
    Required
  </dd>

  <dd>
    The column to use as a join key in the target data element.
  </dd>

  <dt>
    local key 2
  </dt>

  <dd>
    Optional
  </dd>

  <dd>
    The additional column to use as a join key in the local data element.
  </dd>

  <dt>
    external key 2
  </dt>

  <dd>
    Optional
  </dd>

  <dd>
    The additional column to use as a join key in the target data element.
  </dd>
</dl>

## Notes

* The **Lookup** function can only reference one external data element at a time. If external keys from two different elements are referenced, **Lookup** will return the error `Rollup cannot reference more than one external relation`. To help avoid this error and more easily identify the source of external keys, Sigma recommends giving unique names to data elements.

## Examples

### Lookup with one external key

```
Lookup([Customers/Cust Name], [Cust Key], [Customers/Cust Key])
```

Data is inserted into the *Sales* table’s **\[Calc]** column from the *Customer* table’s **\[Cust Name]** column.

These two tables are joined using a single column (join key) from each table. In this case, both join keys are named **\[Cust Key]**.

The function’s *formula* parameter directly references a column in the joined table.

In formulas, reference columns from other tables with the **\[table name/]** prefix (e.g. **\[Customers/Cust Name]**).

![A user enters the provided example formula in the Sigma UI, demonstrating the output over several records in a table.](https://fdr-prod-docs-files-public.s3.us-east-1.amazonaws.com/sigma.docs.buildwithfern.com/5f857bc131fda5668ce4966ceb6d165ac5ef0ce22b3648a2eec7fa2da364b7fd/assets/docs-images/458c4704f0b97a6e643e126db3276fa88603ebe9bbdaf4048af05efd854aa255-Lookup_Screenshot_1_Update.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA6KXJSKKNFOCF7G4B%2F20260726%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260726T002444Z&X-Amz-Expires=604800&X-Amz-Signature=5a89069b902bc425d2a5aaaebdfb9752ff05cab19dcf2b6c5faa3d812e50c332&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject)

### Lookup with two external keys

```
Lookup([Customers/Zip Code], [Cust Name], [Customers/Name], [Cust Key], [Customers/Cust Key])
```

Data is inserted into the *Ordered Items* table’s **\[Calc]** column from *Customer* table’s **\[Zip Code]** column.

The function’s *formula* parameter directly references a column in the joined *Customers* table.

These two tables are joined using two sets of join keys:

* *Order Items’* **\[Cust Name]** column is joined with *Customer*’s **\[Name]** column;
* *Order Items’* **\[Cust Key]** column is joined with *Customer*’s **\[Cust Key]** column

![A user enters the provided example formula in the Sigma UI, demonstrating the output over several records in a table.](https://fdr-prod-docs-files-public.s3.us-east-1.amazonaws.com/sigma.docs.buildwithfern.com/1e124906cad3bc822c1b7cb3345a6fb348b01105815dbdd7618035815770822e/assets/docs-images/e3bf0f22cc6da83de740b117076cf60b5f5664e64b385332b71abc16d0cb97f5-Lookup_Screenshot_2_Update.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA6KXJSKKNFOCF7G4B%2F20260726%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260726T002444Z&X-Amz-Expires=604800&X-Amz-Signature=b53e2a376be94dd20a611d709037d5e8c92013d4e084f6322e0008a0054e59de&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject)

### Lookup with an aggregate result

```
Lookup(Sum([Sales Amounts/Sales Amount]), [Order Number], [Sales Amounts/Order Number])
```

Data is inserted into the *Orders* table’s **\[Calc]** column from *Sales Amount* table’s **\[Sales Amount]** column.

The function’s *formula* parameter uses the Sum function to aggregate values from the *Sales Amount* table’s **\[Sales Amount]** column. For each order in *Orders*, the **Lookup** function returns the sum of all **\[Sales Amount]** values with that **\[Order Number]**.

These two tables are joined using a single set of join keys: *Orders’* **\[Order Number]** column is joined with *Sales Amounts’* **\[Order Number]** column.

![A user enters the provided example formula in the Sigma UI, demonstrating the output over several records in a table.](https://fdr-prod-docs-files-public.s3.us-east-1.amazonaws.com/sigma.docs.buildwithfern.com/4c29db7f2c3100b62318084720344a5a0b6deef28ef1ff4e061859ab9aceccff/assets/docs-images/2270c8da618300ce7c51ef96b6f234b201c343d98a91fed8fc904aff65cd1c6d-Lookup_Screenshot_3_Update.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA6KXJSKKNFOCF7G4B%2F20260726%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260726T002444Z&X-Amz-Expires=604800&X-Amz-Signature=16f4e4456c8208e039fe48a8b53c4ad3fcc119bf4254fe5ade1496d3299770f4&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject)

## Related resources

* [Rollup](/docs/rollup)
* [Add columns through Lookup](/docs/add-columns-through-lookup)