# Creating Aggregations

## Aggregation in the Variable wizard

Aggregations are created in the [**Variable wizard**](https://help.taglo.io/variables/variable-basics/variable-setup).

<figure><img src="https://2847533834-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVy65sax6FVoNo2UTlJ0x%2Fuploads%2F7pGfCS12yGyfrTWKY6Cr%2Fimage.png?alt=media&#x26;token=556ac773-1781-4fc3-8af5-7215e5c52764" alt="Screenshots of the Variable wizard, showing how to create an Aggregation"><figcaption><p>Creating an Aggregation in the Variable dialog</p></figcaption></figure>

To create an Aggregation you will need to perform the following steps, as per the screenshots above:

* Select the `Aggregation` **Variable type** <mark style="color:green;">**(1)**</mark>
* Assign at least one [**Dimension**](https://help.taglo.io/dimensions) to the Variable <mark style="color:green;">**(2)**</mark>
* Set the [**Unit**](https://help.taglo.io/units) for the Variable, in the **Unit step**
* In the **Aggregated Variables step**, select the Variables to be aggregated <mark style="color:green;">**(3)**</mark>. The **Item Statuses** table <mark style="color:green;">**(4)**</mark> shows which items have been selected, and can be used to filter the Variable list to matching items.

{% hint style="warning" %}
Selected Variables must have the correct Unit so that Models can match them correctly to the target items. The below section explains several ways to set up these Variables.
{% endhint %}

## Creating Variables with the correct Unit for Aggregation

Each aggregated Variable must have a Unit which has been modified to match one of the child items of the Aggregation Variable.

For instance, in the above example, the Aggregation Variable (`All costs by cost type`) has a Unit of `GDP` and a Dimension of `Cost type`, which has seven children (`Central staff`, `Gym staff`, etc.).

To match a `Central staff` Variable, we need a Variable with a Unit of `GDP` which has had a `Central staff` modifier applied. To match a `Gym staff` Variable, we need a Variable with a Unit of `GDP` which has had a `Gym staff` modifier applied, and so on for each item.

The screenshot below shows such Units for the `Central staff` and `Gym staff` items.

<figure><img src="https://2847533834-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVy65sax6FVoNo2UTlJ0x%2Fuploads%2FUguEDVL5nJPtHwq9GniL%2Fimage.png?alt=media&#x26;token=b79880be-f38b-4fd8-ad06-f45ab9535d81" alt=""><figcaption><p>Variables with modified Units for Aggregation</p></figcaption></figure>

### Manual creation

These Variables can be created manually. In this case, the Unit should be specified with appropriate modifiers added, in the **Unit step** of the Variable wizard, as demonstrated in the gif below.

<figure><img src="https://2847533834-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVy65sax6FVoNo2UTlJ0x%2Fuploads%2FvmONIfYhPncSMvGSTExI%2FUnit%20context%20modifier.gif?alt=media&#x26;token=dd7a26d0-c075-4be6-8ab6-2d605a716cc9" alt="GIF showing the user setting a context modifier on a unit part in the Unit page of the Variables wizard"><figcaption><p>Setting a Unit Modifier</p></figcaption></figure>

Read [**here**](https://help.taglo.io/units/key-unit-concepts#context) to understand more about Unit Modifiers.

### Automatic creation

If you have not already created the Variables to be aggregated, you can automatically create them in the [**Aggregated Variables step**](#aggregation-in-the-variable-dialog) of the Variable dialog.

To do so, perform the following steps, shown in the example screenshots below:

* Navigate to the **Aggregated Variables step**
* Select any items that you want to create in the **Item statuses** <mark style="color:green;">**(1)**</mark>. By default, all items will be selected. Selected items are indicated by the filter <img src="https://2847533834-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVy65sax6FVoNo2UTlJ0x%2Fuploads%2FbVxi4wVrUuV7Hnmzehua%2Fimage.png?alt=media&#x26;token=e2da0f72-8e02-4056-bfe4-640efbf9f3e2" alt="" data-size="line"> icon.
* Press the **Create selected** button <mark style="color:green;">**(2)**</mark>
* A Variable for each item will be automatically created, each with a correctly modified Unit <mark style="color:green;">**(3)**</mark>
* These new Variables should then be selected and edited as desired

<figure><img src="https://2847533834-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVy65sax6FVoNo2UTlJ0x%2Fuploads%2FdqOZHEK1EQErf8b3tgnA%2Fimage.png?alt=media&#x26;token=372d1301-050e-4029-b1a1-06b96568a314" alt=""><figcaption><p>Example of automatic aggregated Variable creation</p></figcaption></figure>

### Aggregating Variables with Dimensions

You can aggregate Variables which themselves have Dimensions, if some or all of the child items of their Dimension are present in the Aggregation Variable.&#x20;

The screenshot below shows an example of this feature. In this case, the `All costs by cost type` Variable references a Variable <mark style="color:green;">**(1)**</mark> called `Costs: Recurring`, which has the `Simple recurring cost type` Dimension applied.&#x20;

The `Simple recurring cost type` Dimension has four cost items as children: `Marketing cost`, `Rent`, `Equipment`, and `IT & Technology` <mark style="color:green;">**(2)**</mark>. Each of these four items are also present in the `Cost type` Dimension that is applied to `All costs by cost type`. Hence selecting `Costs: Recurring` means that Models is able to determine values for those four items, as indicated in the **Item statuses control&#x20;**<mark style="color:green;">**(3)**</mark>.

{% hint style="info" %}
In this case, you do not need to apply any Modifiers to the Unit of `Costs: Recurring.`&#x20;

`Costs: Recurring` already has Unit `GBP`, and the relevant Modifiers are applied in the background by the `Simple recurring cost type` Dimension
{% endhint %}

<figure><img src="https://2847533834-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVy65sax6FVoNo2UTlJ0x%2Fuploads%2FlQ3Y5lqg5qnqZFlmGVAj%2Fimage.png?alt=media&#x26;token=34ebe74f-7433-4574-be58-6a8f258f6d48" alt=""><figcaption><p>Example of an Aggregation referencing a Variable with a Dimension</p></figcaption></figure>
