---
title: "Aggregations"
url: https://festi.dev/8.0/DGS/Aggregations/
---

# Aggregations

This section describes column totals.

```xml
<aggregations>
    <aggregation field="total_payment" type="custom" />
    <aggregation field="commission" type="avg" />
    <aggregation field="tax" />
</aggregations>
```

*type* - can have values `avg`, `sum`, `custom`. If `type` is not specified,
 it defaults to `sum`.

When using the `custom` type, you need to add a listener to the `Store::EVENT_ON_AGGREGATIONS` event:

```xml
<listener event="<?php echo Store::EVENT_ON_AGGREGATIONS; ?>"
                  plugin="Finance"
                  method="onMonthlyPaymentReportAggregationData" />
```

```php 
/**
 * @event Store::EVENT_ON_AGGREGATIONS
 * @param StoreAggregationEvent $event
 * @throws SystemException
 */
public function onMonthlyPaymentReportAggregationData(StoreAggregationEvent &$event)
{

    $values = &$event->getValues();
    $data = &$event->getData();

    $values['total_payment'] = 0;
    foreach ($data as $row) {
        $values['total_payment'] += (float) $row['total_payment'];
    }

}

```
