---
schema_version: "1"
id: 23e1ca7ac60501461924ea0ceb8877055aae1d690db60840ed0f049fd7bbd5ee
title: Aggregate and Group Data to a Different Grain
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/analytics/264-0-0/bi_integrate_data_prep_recipe_aggregate_or_group.md
canonical_url: https://help.salesforce.com/s/articleView?id=analytics.bi_integrate_data_prep_recipe_aggregate_or_group.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 6ff7f9d51ee5f7daa8e31d5d5e842b07ceb91a475897a1492d9fb62fc7425103
description: Large datasets can be hard to digest due to the amount of information and low-grain details. Aggregation allows these datasets to be rolled up to a higher granularity, thus allowing users to create recurring summary statistics and join datasets with different granularities. You can also aggregate data to perform calculations on grouped records without aggregating the measures. For instance, group by website session IDs and then calculate the average time on each page and total number of clicks.
products:
  - CRM Analytics
  - Cross Cloud
release: "264"
---
# Aggregate and Group Data to a Different Grain

Large datasets can be hard to digest due to the amount of information and low-grain details. Aggregation allows these datasets to be rolled up to a higher granularity, thus allowing users to create recurring summary statistics and join datasets with different granularities. You can also aggregate data to perform calculations on grouped records without aggregating the measures. For instance, group by website session IDs and then calculate the average time on each page and total number of clicks.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in Salesforce Classic and Lightning Experience.</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available with CRM Analytics, which is available for an extra cost in <strong>Enterprise</strong>, <strong>Performance</strong>, and <strong>Unlimited</strong> Editions. Also available in <strong>Developer</strong> Edition.</td></tr></tbody></table>

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/images/icon_note.png)

Note To aggregate rows in a Data Prep recipe, see [Aggregate Node: Roll Up Data to a Higher Level](https://help.salesforce.com/s/articleView?id=analytics.bi_integrate_recipe_aggregate_rows.htm&release=264.0.0&type=5 "Use an Aggregate node to roll up data to a higher granularity in CRM Analytics. You can aggregate using: unique, sum, average, count, maximum, and minimum. You can group by any dimension or date column. You can also pivot dimensions as columns. For example, you can group opportunities by account to get account-level details, like total opportunity amount, average number of cases, and the average days to close an opportunity for each account. You can then pivot on account type to analyze each combination of account and account type.").

You can add groups, aggregates, or both. Group by dimensions or date windows to roll up the records to a higher grain. For example, group daily logs by month so you can join that data with your monthly datasets. Aggregate measures to the new grouping granularity. You can use the following aggregate functions on measure columns: sum, unique, avg, count, max, and min.

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/images/icon_note.png)

Note

To prevent double counting, exclude aggregated values that don’t match the grain of the dataset. For example, the following dataset’s grain is opportunity—each record represents an opportunity. However, the grain of the Account Annual Revenue aggregated value is account. If a user doesn’t know the dataset grain and adds all Account Annual Revenue values, he would double count annual revenue for accounts with multiple records. To prevent double counting, move Account Annual Revenue to a different dataset where the grain is account.

![The account annual revenue is listed three times--once for each of the three opportunities tied to the same ACME account.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/bi/images/bi/bi_integrate_data_prep_recipe_aggregate_grainIssue.png)

1. On the recipe page, click the Aggregation button (![Add data button](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/bi/images/bi/bi_button_aggregation.png)).
2. To change the granularity of the data, add groups. For example, group by account name to aggregate metrics by this dimension.
3. To view aggregated metrics for each grouping, add aggregates. For example, calculate the average age for opportunities to close, total amounts, average amounts, and total number of deals. Because these opportunities are grouped by account name, these aggregates provide key metrics about each account.
    
    ![Select the groups and aggregates on the left.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/bi/images/bi/bi_recipe_aggregates_groups_configure.png)
4. Click **Done**.
    
    Notice that the aggregates and group-by fields are the only fields included in the output. All other fields from the source dataset are excluded—you can’t perform transforms on them in this recipe anymore.
5. Click **Save** | **Save Recipe**.

When you run the recipe, CRM Analytics generates a new dataset that contains the aggregates specified in the recipe and a grain determined by the groups. In the example, we see the aggregates for each account.

![The new dataset has a row for each account and shows key metrics for each.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-bi-264-0-0-production-enus/ec791473-f5b4-4f64-a656-9104f455d966/bi/images/bi/bi_integrate_data_prep_recipe_aggregateByDim_results.png)