> For the complete documentation index, see [llms.txt](https://docs.antsomi.com/cdp-365-user-guide-en/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.antsomi.com/cdp-365-user-guide-en/insights/reports/blend-multiple-data-sources-in-a-chart/use-blending-to-reaggregate-data.md).

# Use blending to reaggregate data

Learn how to work with previously aggregated data.

Reaggregation is a common need in data visualization. This article will help you understand the concept of reaggregation and how to achieve it in Insights using data blending.

One example of reaggregation is calculating the **average of averages**. For example, say you have a table of stock price changes:

| **Sector** | **Ticker** | **Price Change** |
| ---------- | ---------- | ---------------- |
| Tech       | GOOG       | +6               |
| Tech       | AAPL       | +5               |
| Tech       | MSFT       | -3               |
| Tech       | NFLX       | -1               |
| Energy     | E1         | +2               |
| Energy     | E2         | +10              |
| Energy     | E3         | -3               |
| Finance    | F1         | -6               |

The average price change for this data is a simple aggregation.

| **Average of Price Change** |
| --------------------------- |
| **1.25**                    |

To calculate the average price change for every sector, you'd group this table by the *Sector* dimension.

| **Sector** | **Average of Price Change** |
| ---------- | --------------------------- |
| Tech       | **1.75**                    |
| Energy     | **3**                       |
| Finance    | **-6**                      |

To reaggregate this data, you'd apply another aggregation function, for example, applying average again:

| **Average of Average of Price Change** |
| -------------------------------------- |
| **-0.42**                              |

### **Reaggregation in Insights**

To reaggregate metrics in Insights, use [data blending](broken://pages/-Mg-eddkiH4GsFKtbWPG). Blending lets you work around the fact that previously aggregated fields are set to the AUTO field type. You can't change this field type, nor can you apply another aggregation function to such fields.

For example, to find the average change of stock prices per sector in Insights, you'd create a blend configuration that joins the same data source with itself. Use *Sector* as the join key, and include the *Average Price Change* metric in both the left and right data sources, as shown below:

<figure><img src="https://826840553-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbtU4vFUxT5JkWYHePuoX%2Fuploads%2FZHUcWmo6fKtduHpNfss4%2Fimage.png?alt=media&amp;token=c6b3a6f3-4f77-4d0e-a56a-73c01e27d6df" alt=""><figcaption><p>Data blending example </p></figcaption></figure>

​![1](https://lh6.ggpht.com/Y1gFfIuXsqvwPm6JZlQbsQvHAWwGUhdfVDrylouYaHbNR9W0X1ti8yKW6LNhoKi5SMIGypNL=w50-h50)*Sector*![2](https://lh5.ggpht.com/s-ZxOC9CQan_v8BIDttLvZFvBjpep--6rAptcvXxsyeBeX6cZnXm8e4BveGGSDOWOOtIK6oO=w50-h50)*Average Price Change*This blended data source lets you apply new aggregations on the previously aggregated *Price Change* field.

**Blending disaggregates data**

Blending data creates a new table from the columns that you select in the blend configuration. Metrics in the new table are treated as unaggregated numbers.Because *Price Change* is no longer an aggregated metric, you can now apply a new aggregation function on it. The table below shows the results of creating a new metric AVG(*Price Change*) with the previously aggregated numbers:

<figure><img src="https://826840553-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbtU4vFUxT5JkWYHePuoX%2Fuploads%2FpjytbsO7OUqZdVUjfFwt%2Fimage.png?alt=media&amp;token=07198899-7de8-4f0c-b447-895325896c22" alt=""><figcaption><p>Average price change</p></figcaption></figure>

![Average price change](https://lh3.googleusercontent.com/cq8_5JENQQTmGirfQnbMrjkcf5pM3R6uWUE75yaqhS0cvn2p8GWHdThDcPS9Sp0Dnfc=w1400)

![1](https://lh6.ggpht.com/Y1gFfIuXsqvwPm6JZlQbsQvHAWwGUhdfVDrylouYaHbNR9W0X1ti8yKW6LNhoKi5SMIGypNL=w50-h50) *Price Change*

This new metric reaggregates the numbers **1.75, 3** and **-6** and displays their average: **-0.42** .

### Create a ratio column using blending

Another use for blending is to create ratio metrics with already aggregated numbers. Say you want to create a ratio column that divides one metric by another.

In this example, we'll use two fields; *Clicks* and *Impressions*, coming from two different data sources.

| **Website**  | **Clicks** |
| ------------ | ---------- |
| google.com   | 300        |
| facebook.com | 400        |
| twitter.com  | 200        |

| **Website**  | **Impressions** |
| ------------ | --------------- |
| google.com   | 2000            |
| facebook.com | 2500            |
| twitter.com  | 2000            |

You can create a ratio column with a calculated field *Clicks/Impressions* by blending these two data sources.

| **Website**     | **Clicks** | **Impressions** | **Clicks / Impressions** |
| --------------- | ---------- | --------------- | ------------------------ |
| google.com      | 300        | 2000            | 0.15                     |
| facebook.com    | 400        | 2500            | 0.16                     |
| twitter.com     | 200        | 2000            | 0.1                      |
| **Grand Total** | 900        | 6500            | **0.41**                 |

All the rows of *Clicks/Impressions* have correct information except the summary row which shows the sum of the ratio column **`SUM(`*****`Clicks / Impressions`*****`)`**. This happens because *Clicks/Impressions* is calculated for each row \[0.15, 0.16, 0.1] and then the `SUM` function is applied to it. \[0.15 + 0.16 + 0.1 = 0.41].

The correct result is **900/6500 = 0.14 .**&#x59;ou can do this by calculating the ratio column values using the formula **`SUM(`*****`Clicks`*****`) / SUM(`*****`Impressions`*****`)`.**

| **Website**     | **Clicks** | **Impressions** | **SUM(Clicks) / SUM(Impressions)** |
| --------------- | ---------- | --------------- | ---------------------------------- |
| google.com      | 300        | 2000            | 0.15                               |
| facebook.com    | 400        | 2500            | 0.16                               |
| twitter.com     | 200        | 2000            | 0.1                                |
| **Grand Total** | 900        | 6500            | **0.14**                           |

In this case, the summary row shows **`SUM( SUM(`*****`Clicks`*****`) / SUM(`*****`Impressions`*****`) )`. `SUM(`*****`Clicks`*****`)`** \[900] is divided by **`SUM(`*****`Impressions`*****`)`**\[6500] to give **0.14.** The **`SUM`** function is then applied to it again. The result is still **0.14**.


---

# 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.antsomi.com/cdp-365-user-guide-en/insights/reports/blend-multiple-data-sources-in-a-chart/use-blending-to-reaggregate-data.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.
