# Group Aggregates

The text of the group header row is a formatted string with the following parameters:

* **{0}** – **Property name** –the name of the RadGridView column by which the grouping is performed;

* **{1}** – **Group value**

* **{2}, {3} …** - **Aggregates values**

You can define the format of the group header row by using the **GroupDescriptor Format** property. Its default value is **“{0}: {1}”**. The following two examples demonstrate how you can use the group aggregates. Full list of the available expressions can be found here:<http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx>

#### Example 1: Adding the Count Aggregate

```C#
GroupDescriptor descriptor = new GroupDescriptor();
descriptor.GroupNames.Add("Country", ListSortDirection.Ascending);
descriptor.Aggregates.Add("Count(Country)");
descriptor.Format = "{0}: {1} has {2} records in its group.";

this.radGridView1.GroupDescriptors.Add(descriptor);
```

```VB.NET
Dim descriptor As New GroupDescriptor()
descriptor.GroupNames.Add("Country", ListSortDirection.Ascending)
descriptor.Aggregates.Add("Count(Country)")
descriptor.Format = "{0}: {1} has {2} records in its group."

Me.RadGridView1.GroupDescriptors.Add(descriptor)
```

![WinForms RadGridView Adding the Count Aggregate](https://www.telerik.com/products/winforms/documentation/assets/531f5c74144f03675cb537424b2c7b0a/gridview-group-aggregates001.png)

#### Example 2: Adding and Formatting Several Aggregates

```C#
GroupDescriptor descriptor = new GroupDescriptor();
descriptor.GroupNames.Add("ShipName", ListSortDirection.Ascending);
descriptor.Aggregates.Add("Count(ShipName)");
descriptor.Aggregates.Add("Max(Freight)");
descriptor.Aggregates.Add("Avg(Freight)");
descriptor.Format = "The ship {1} has {2} item(s) with maximum freight {3} and average freight of {4:c2} per ship.";

this.radGridView1.GroupDescriptors.Add(descriptor);
```

```VB.NET
Dim descriptor As New GroupDescriptor()
descriptor.GroupNames.Add("ShipName", ListSortDirection.Ascending)
descriptor.Aggregates.Add("Count(ShipName)")
descriptor.Aggregates.Add("Max(Freight)")
descriptor.Aggregates.Add("Avg(Freight)")
descriptor.Format = "The ship {1} has {2} item(s) with maximum freight {3} and average freight of {4:c2} per ship."

Me.RadGridView1.GroupDescriptors.Add(descriptor)
```

![WinForms RadGridView Adding and Formatting Several Aggregates](https://www.telerik.com/products/winforms/documentation/assets/496a0059269a6976658cfd3793d9b7a3/gridview-group-aggregates002.png)

## See Also

* [Basic Grouping](https://www.telerik.com/products/winforms/documentation/controls/gridview/features/grouping/basic-grouping)

* [Custom Grouping](https://www.telerik.com/products/winforms/documentation/controls/gridview/features/grouping/custom-grouping)

* [Events](https://www.telerik.com/products/winforms/documentation/controls/gridview/features/grouping/events)

* [Formatting Group Header Row](https://www.telerik.com/products/winforms/documentation/controls/gridview/features/grouping/formatting-group-header-row)

* [Groups Collection](https://www.telerik.com/products/winforms/documentation/controls/gridview/features/grouping/groups-collection)

* [Setting Groups Programmatically](https://www.telerik.com/products/winforms/documentation/controls/gridview/features/grouping/setting-groups-programmatically)

* [Sorting group rows](https://www.telerik.com/products/winforms/documentation/controls/gridview/features/grouping/sorting-group-rows)

* [Using Grouping Expressions](https://www.telerik.com/products/winforms/documentation/controls/gridview/features/grouping/using-grouping-expressions)
