# Summarising Variables

## Overview

When referencing a [**Variable**](/variables/variable-basics.md) with one or more [**Dimensions**](/dimensions/introduction-to-dimensions.md), from a Variable with different Dimensions, we can summarise the target Variable in several different ways.

<table><thead><tr><th width="220.33333333333331">Summarise method</th><th>Details</th></tr></thead><tbody><tr><td><strong>Summary Line</strong></td><td>If the target Variable has a <a href="/pages/YjhPpbYazLVzwYAAY5qp#row-summary"><strong>row summary</strong></a>, the value of the row summary is returned</td></tr><tr><td><strong>New Summary</strong></td><td>Creates a custom summary - you can choose which lines of the target Variable are summed together</td></tr><tr><td><strong>Sum based on third Variable</strong></td><td>Sums Variable rows together according to a categorisation made in a third Variable</td></tr></tbody></table>

{% hint style="info" %}
By default, if you create a reference to a Variable which has Dimensions that do not match the Calculation Variable, a Summary Line reference will be created. If a Row Summary is not present in the target Variable, a New Summary adding together all lines of the target Variable will be created.
{% endhint %}

## Referencing the Summary Line

<figure><img src="/files/3imVR0uSmKeQhKAyGvJM" alt=""><figcaption><p>Example Summary Line reference</p></figcaption></figure>

If the target Variable already has a [**row summary**](/variables/summaries.md#row-summary) line, your Calculation can simply reference that summary. This is indicated by an `[All]` suffix in the Variable reference.

This reference will often be created for you by default. If you need to create the reference yourself, edit the [**Calculation Part**](/calculations/calculation-parts.md) and select the option `Reference the SUMMARY line of the Variable` in the **Reference type** step, as shown below.

<figure><img src="/files/KztqDZVDSTWtKaA2Ygff" alt=""><figcaption><p>Creating a Summary Line reference</p></figcaption></figure>

## Creating a New Summary

### Example 1

<figure><img src="/files/R6WfzasDd93YRrC95rUm" alt=""><figcaption><p>Example New Summary reference</p></figcaption></figure>

In the above example, we have created a Variable, `Platinum Revenues`, that sums together the `Platinum` items of the `Revenues by region and membership type` Variable.

This is achieved by creating a **New Summary** reference, via the following steps:

* Edit the Calculation Part and navigate to the **Reference type** page, as shown in the screenshot below
* Select the `Create a NEW SUMMARY` option <mark style="color:green;">**(1)**</mark> - this displays a new Variable summary step in which you can select the desired summary options <mark style="color:green;">**(2)**</mark>
* In this case, we need to select an option for each of the two target Dimensions, `Region` and `Membership tier`. As we are adding together the `Platinum` lines, we select **Sum** for `Region`, and `Platinum` for `Membership Tier`

<figure><img src="/files/XGOz9p09tc13LisIW39D" alt=""><figcaption><p>Creating a New Summary: Example steps</p></figcaption></figure>

### Example 2

<figure><img src="/files/5ANwArViMGSTFoPzlXIP" alt=""><figcaption><p>Example New Summary reference</p></figcaption></figure>

In this example, we have created a Variable, `Revenues by region`, which has the `Region` Dimension applied, and we want to sum together all revenues for each region.

To do this, we follow the same steps as in Example 1, but this time we have an option <mark style="color:green;">**(1)**</mark> to link the `Region` Dimension in the target Variable to the `Region` Dimension in the Calculation Variable.

{% hint style="info" %}
In this situation, Models would automatically generate this summary when the reference is created, as it can see that the `Region` Dimension is present in both Variables.
{% endhint %}

<figure><img src="/files/j1COPqjIjTKklg6DeWHy" alt=""><figcaption><p>Creating a New Summary: Example steps</p></figcaption></figure>

## Summarising by a third Variable

<figure><img src="/files/XLBg8WXGP2YQ9iVJ6ZsK" alt=""><figcaption><p>Example Summary by a third Variable</p></figcaption></figure>

In the example above, we have seven cost items, which we want to assign to either `Capex` or `Opex` and then automatically sum up the totals for the two types of cost.

We can achieve this in a single Variable reference as follows:

* Edit the Calculation Part and navigate to the **Reference type** page, as shown in the screenshot below
* Select the `SUM lines together based on a third Variable` option <mark style="color:green;">**(1)**</mark> - this displays a new Variable selector step in which you can select the assignment Variable <mark style="color:green;">**(2)**</mark>
* In this step, select a Variable with which to perform the assignment. This Variable will need to have the same Dimensions as the referenced Variable. By default, this list will be filtered to Variables with the correct Dimensions.

{% hint style="info" %}
Create the assignment Variable by using the [**Validation data type**](/variables/variable-basics/variable-setup.md#validation-dimension) - in this case using `Opex/Capex` as the Validation Dimension.
{% endhint %}

<figure><img src="/files/aZqOvjkggJMG69UfuwTO" alt=""><figcaption><p>Summarising based on a third Variable: Example steps</p></figcaption></figure>


---

# Agent Instructions: 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:

```
GET https://help.taglo.io/calculations/calculation-parts/variable-references/summarising-variables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
