# 14. Manage aggregation

While working with Power BI table/matrix reports, we would sometimes like to apply custom aggregations for the measures in a specific report (e.g., average quantity sold) instead of using the default aggregation used in a data model (e.g., the sum of quantity sold).&#x20;

Inforiver’s aggregation feature allows you to override the native Power BI aggregation for measures without having to make extensive model-level changes. You can set aggregation at measure/column-level, hierarchy-level, and specify aggregation for the row and column subtotals/grand totals.

**Row aggregation:** You can specify the aggregation to be applied on row subtotals and grand total.

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2FEwKXrf7zvPFeZiDEd2jp%2Fimage.png?alt=media&#x26;token=b698bb10-fa42-40a2-806d-4a4a6fb0543f" alt=""><figcaption><p>Row aggregation</p></figcaption></figure>

**Column aggregation: Y**ou can specify the aggregation to be applied on the column grand total and subtotals.

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2FDHFI6mOXO5MxG8oAdBA4%2Fimage.png?alt=media&#x26;token=a12e89be-0c45-4ff9-98a9-b4043597d58b" alt=""><figcaption><p>Column aggregation</p></figcaption></figure>

Click the **Aggregation** button in the **Insert** ribbon to open the **Manage Aggregation** interface.

### 1. Measure level aggregation

You can specify the row and column aggregation for individual measures and columns from the **Measure** tab. Select the aggregation type from the dropdown against the measure name.

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2FBMrIQirc5o61CrdwkybN%2Fimage.png?alt=media&#x26;token=9111d28e-dce8-412c-b355-b124a7ce3fec" alt=""><figcaption><p>Measure level row and column aggregation</p></figcaption></figure>

* **Sum** set as row aggregation for 2024 Plan: The sum of the child rows will be used to populate the row subtotal and grand total.
* **Maximum** set as row aggregation for 2024 Actuals: The maximum value in the child rows will be used to populate the row subtotal and grand total.
* **Minimum** set as column aggregation for 2024 Actuals and Plan: The minimum values in the columns will be used as the column grand total and subtotal.

### 2. Aggregation types

{% hint style="info" %}
The interface shown in the screenshots in this section has changed slightly in newer versions but the functionality remains the same.
{% endhint %}

#### Native

By default, the 'Native' option is applied which follows the native summarization set in Power BI.&#x20;

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2Fuw0hVZvnaCuJz86mvEP8%2Fimage.png?alt=media&#x26;token=23412d7d-eaf1-4aeb-9427-6c4ba48bfe0a" alt=""><figcaption><p>Native aggregation at report level</p></figcaption></figure>

#### None

Choosing 'None' performs no aggregations for the selected measure or hierarchy. In the example below, the 'Discount' measure is not aggregated.

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2F4IDPIa9hDMaGmA414O1U%2Fimage.png?alt=media&#x26;token=4cc83e32-5609-4c0b-9b7d-99ab8791f0a7" alt=""><figcaption><p>Aggregation is 'None'</p></figcaption></figure>

#### Sum

'Sum' aggregation displays the sum of the immediate child nodes as the aggregate. In the highlighted example, the 'Computers' category is the sum of its immediate child nodes.

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2F4zUrd4vwZBs2YhEUWwNA%2Fimage.png?alt=media&#x26;token=0d406fb3-793f-4baf-8f07-d99c097e5b70" alt=""><figcaption><p>Sum aggregation type at report level</p></figcaption></figure>

#### Minimum

'Minimum' aggregation displays the minimum value of the immediate child nodes as the aggregate. In the below example, the 'Computers' category displays the minimum value of its immediate child nodes which is 'Computers Accessories'.

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2F8nnDyDhqR3apo3ip41Nk%2Fimage.png?alt=media&#x26;token=0c1184c0-bc43-4b39-b54d-0826ce404924" alt=""><figcaption><p>Minimum aggregation type at report level</p></figcaption></figure>

#### Maximum

'Maximum' aggregation displays the maximum value of the immediate child nodes as the aggregate. In the below image, the 'Computers' category displays the maximum value of its immediate child nodes which is 'Projectors and Screens'.

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2F75WS9JDaGVw6LNNrmngT%2Fimage.png?alt=media&#x26;token=a512cb06-c0a8-4a2f-8245-e6e912ccacd1" alt=""><figcaption><p>Maximum aggregation type at report level</p></figcaption></figure>

#### Average (Children)

'Average (Children)' aggregation displays the average value of the immediate child nodes as the row aggregation. In the below example,  'Computers' category is calculated as the average of the immediate child nodes i.e. the 'SubCategory' field.

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2F9uq6EUtSYNAStBvZHNUO%2Fimage.png?alt=media&#x26;token=1e31529f-fd52-437b-a154-a7bf51817d52" alt=""><figcaption><p>Average(children) aggregation type at report level</p></figcaption></figure>

#### Average (Leaf)

'Average (Leaf)' aggregation displays the average value of all the leaf nodes of the row category as the row aggregation. In the below example, 'Computers' is calculated as the average of the leaf nodes i.e. the 'Class' field.

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2FLSdZKwcnTx8vamPMYee9%2Fimage.png?alt=media&#x26;token=e2449f0b-560a-40ab-b765-e7d8e3755747" alt=""><figcaption><p>Average(leaf) aggregation type at report level</p></figcaption></figure>

#### Standard deviation

'Standard deviation' aggregation displays the standard deviation of the child rows as the aggregate. In the below example, 'Computers' is calculated as the standard deviation of its immediate child nodes.

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2FWQ14WjxWfB9y5TPC8XB6%2Fimage.png?alt=media&#x26;token=375faa13-5ae3-4f1f-8238-7dc0ac8c1d2a" alt=""><figcaption><p>Standard Deviation as aggregation type at report level</p></figcaption></figure>

#### Visible rounding

'Visible rounding' aggregation rounds off values in a way that the individual values add up properly to the subtotal' and grand total. This is a very common requirement in external financial statement reporting such as the income statement and balance sheet reporting.

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2FbHOPDFvQhMeVAIbgjuMs%2Fimage.png?alt=media&#x26;token=b0859c82-c748-4e44-988d-8c21584b015e" alt=""><figcaption><p>Visible Rounding as aggregation type at report level</p></figcaption></figure>

#### Weighted Average

In weighted average aggregation, each child value in a row category is multiplied with weights taken from another measure which are then summed and divided by the total weight.&#x20;

Weighted moving average = (w1\*a1 + w2\*a2 +...+wn\*an) / (w1+w2+...+wn),

where

n= number of child rows in the row category

w1,w2,w3,....wn = weights (data from measure 1)

a1,a2,a3,........an = data from measure 2

This type of averaging is sometimes more accurate than simple averaging as it considers the varying importance of the data points. This also smoothens any price point fluctuations and is commonly used for inventory accounting, portfolio analysis, statistical research, planning, and forecasting.&#x20;

The example below calculates the weighted average using the costs and quantities in each region.

i.e., Average Cost for ***Paseo*** = \[(Quantity\*Cost) *in Canada*  + (Quantity\*Cost) *in* *France* + (Quantity\*Cost) *in United States* + (Quantity\*Cost) *in Mexico* + (Quantity\*Cost) *in Germany* ] / Total Quantity&#x20;

Note that weighted average is a row aggregation method – only the total and subtotal rows will reflect the calculation.

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2FGVcu6z3ZKJcO79mbvPcQ%2Fimage.png?alt=media&#x26;token=d0a9bc37-049b-464a-90ac-900811cc16c2" alt=""><figcaption><p>Weighted Average as the row aggregation type for data input measure</p></figcaption></figure>

{% hint style="info" %}
'Weighted Average' aggregation can be applied only to data input, formula, and forecast measures.&#x20;
{% endhint %}

#### First

This aggregation type is often used in time-series data or any sequential dataset. The 'First' aggregation type displays the first value from the set of immediate child nodes. This is especially useful when we need to record the dataset's initial state or value.&#x20;

In the example below, we have captured the first month's value in a year.

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2FRcA3wstrk8v4NzYRiynF%2Fimage.png?alt=media&#x26;token=e6d5c673-0fb5-4a2e-b8ff-6f295075adc6" alt=""><figcaption><p>'First' aggregation type </p></figcaption></figure>

#### Last

This aggregation type is used in time-series data or any sequential dataset. The 'Last' aggregation type displays the last value or the latest value from the set of immediate child nodes. This is useful when we need the most recent value in a dataset, especially when budgeting for the following year by carrying over the previous year's value.&#x20;

In the example below, we have captured the value from the last month of the year.

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2FO0fXzINsxuvqkZZk3njm%2Fimage.png?alt=media&#x26;token=f1ce9b5e-f46c-4bb0-9f54-344b8c7490e4" alt=""><figcaption><p>'Last' aggregation type</p></figcaption></figure>

#### Resources

[Change & manage aggregation in Power BI matrix](https://inforiver.com/blog/feature-highlights/define-visual-aggregation-power-bi-table-matrix/)
