---
title: "Aggregation Functions"
description: "Lucanet xP&A has three types of Aggregation Functions that determine how a variable 'rolls up' Categories, Time, and Data respectively."
source_url: https://support.lucanet.cloud/en/documentation/xp-a---extended-planning-and-analysis/modeling-your-data/create-edit-variables/aggregation-functions
language: en
last_updated: 2023-08-16
---
# Aggregation Functions

## Overview

Lucanet xP&A has three types of aggregation functions that determine how a variable 'rolls up' **Dimensions**, **Time**, and **Data** respectively.

## Aggregation Functions

The following aggregation functions are available:

#### Dimension aggregation

By default, Lucanet xP&A will take the **Sum** of each dimension item's value to aggregate the variable. However, there are examples where **Sum** does not make sense, e.g. if you have split **Bonus** % by **Department**, it might be more appropriate to see the average of the **Departments**' **Bonus**%, not the **Sum**.

For more information on dimension aggregation, see [Dimension Aggregation](https://support.lucanet.cloud/en/documentation/xp-a---extended-planning-and-analysis/modeling-your-data/using-dimensions/aggregating-dimensions.md).

#### Time aggregation

In charts and tables, and in roll-up columns in the spreadsheet, Lucanet xP&A automatically rolls up a variable's values across time.

**For example**: If your model is monthly and you have a revenue variable, then xP&A can automatically summarize the total revenue in each year or each quarter. The **time aggregation** function determines how this roll-up happens, and whilst the default is **Sum**, there are examples where you would want other methods (e.g. for balance sheet items like **Cash**, you would want to take the final amount for the 2023 balance, not the sum of all the 2023 balances).

{% info-box %}
Note that the **Time Aggregation** setting of a variable also determines how a variable is 'rolled up' to a model with a higher-level granularity, for example from a weekly model to a monthly model. For more information, see [Different Time Granularities](https://support.lucanet.cloud/en/documentation/xp-a---extended-planning-and-analysis/modeling-your-data/working-with-time/time-granularities.md).
{% /info-box %}

#### Data aggregation

The **data aggregation** function on a [variable connected to data](https://support.lucanet.cloud/en/documentation/xp-a---extended-planning-and-analysis/integrating-data/working-with-integrated-data/linking-variables-to-integrated-data.md) determines aggregates transactions within each data item linked to a variable. This is usually always going to be **Sum**(which is the default), but there are examples where you might want it to use **Average**, **Median**, **Initial**, **Final**, or **Count** instead.

**Example**:

If you have daily cumulative data in your data source, and are pulling that into a weekly or monthly model in xP&A, Sum wouldn't make sense (as that would be adding multiple cumulative numbers together), so you might choose **Final** instead. E.g.

2022-12-20 Cumulative User Count 33

2022-12-21 Cumulative User Count 35

**Sum** would return 68 whereas **Final** would return 35 (the true ending users for the week/month).

## Aggregation Methods

The default method for all three aggregation functions ( **Dimensions**, **Time**, **Data**) is **Sum**, but there are other methods available:

- **Average**
- **Min/Max** (not available for Data/Time Aggregation)
- **Final/Initial** (not available for Dimension Aggregation)
- **Median** (not available for Time Aggregation)
- **Formula** (not available for Data Aggregation)

## Using an Aggregation Function

The aggregation of a variable can be set via the variable's context menu.

{% stepper %}
{% stepper-step %}
Click to open the context menu.
{% /stepper-step %}
{% stepper-step %}
Click **Aggregation**.

Context menu of a variable

{% /stepper-step %}
{% stepper-step %}
Click **Aggregation**. The context menu is displayed as follows:

Menu 'Aggregation'

{% /stepper-step %}
{% stepper-step %}
Choose the desired **aggregation method**.

{% /stepper-step %}
{% /stepper %}
And you can find this setting by right-clicking on a **variable in a formula**:

Menu 'Aggregation Function'
