> For the complete documentation index, see [llms.txt](https://docs.tonic.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tonic.ai/app/generation/generators/generator-reference/cross-table-sum.md).

# Cross Table Sum

Links columns in two tables. This column value is the sum of the values in a column in another table.

This generator does not provide a preview. The sums are not computed until the other table is generated.

For example, a **Customers** table contains a **Total\_Sales** column. The **Transactions** table uses a foreign key **Customer\_ID** column to identify the customer who made the transaction, and an **Amount** column that contains the amount of the sale. The **Customer\_ID** value in the **Transactions** table is a value from the **ID** primary key column in the **Customers** table.

You assign the Cross Table Sum generator to the **Total\_Sales** column. In the generator configuration, you indicate that the value is the sum of the **Amount** values for the **Customer\_ID** value that matches the primary key **ID** value for the current row.

For the **Customers** row for ID `123`, the **Total\_Sales** column contains the sum of the **Amount** column for **Transactions** rows where **Customer\_ID** is `123`.

## Characteristics <a href="#cross-table-sum-characteristics" id="cross-table-sum-characteristics"></a>

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top"><strong>Consistency</strong></td><td valign="top">No, cannot be made consistent.</td></tr><tr><td valign="top"><strong>Linking</strong></td><td valign="top">No, cannot be linked.</td></tr><tr><td valign="top"><strong>Differential privacy</strong></td><td valign="top">No</td></tr><tr><td valign="top"><strong>Data-free</strong></td><td valign="top">No</td></tr><tr><td valign="top"><strong>Allowed for primary keys</strong></td><td valign="top">No</td></tr><tr><td valign="top"><strong>Allowed for unique columns</strong></td><td valign="top">No</td></tr><tr><td valign="top"><strong>Uses format-preserving encryption (FPE)</strong></td><td valign="top">No</td></tr><tr><td valign="top"><strong>Privacy ranking</strong></td><td valign="top">3</td></tr><tr><td valign="top"><strong>Generator ID (for the API)</strong></td><td valign="top"><a href="/pages/OnB96XREUMxGohHqnbuN"><code>CrossTableAggregateGenerator</code></a></td></tr></tbody></table>

## How to configure <a href="#cross-table-sum-configure" id="cross-table-sum-configure"></a>

To configure the generator:

1. From the **Foreign Table** dropdown list, select the table that contains the column for which to sum the values.
2. From the **Foreign Key** dropdown list, select the foreign key.\
   \
   The foreign key identifies the row from the current table that is referred to in the foreign table.
3. From the **Sum Over** dropdown list, select the column for which to sum the values.
4. From the **Primary Key** dropdown list, select the primary key for the current table.
5. If [Structural data encryption](/app/generation/generators-assign-config/generators-data-encryption-config.md) is enabled, then to use it for this column, in the advanced options section, toggle **Use data encryption process** to the on position.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.tonic.ai/app/generation/generators/generator-reference/cross-table-sum.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
