---
title: "Introducing Summary Calculation Support for Selected Rows in WPF DataGrid"
published_at: "2020-01-29T12:00:24+00:00"
modified_at: "2025-04-23T09:39:24+00:00"
url: "https://www.syncfusion.com/blogs/post/summary-calculation-selected-rows-wpf-datagrid"
excerpt: "We are happy to announce that in our Essential Studio® 2019 Volume 4 release, we added summary calculation support for selected rows in the WPF DataGrid control. This blog provides a walk-through of how to calculate summaries for selected rows..."
taxonomy_category:
  - "WPF"
taxonomy_post_tag:
  - "DataGrid"
  - "summary"
  - "WPF"
---

# Introducing Summary Calculation Support for Selected Rows in WPF DataGrid

[Amal Raj Umapathy Selvam](https://www.syncfusion.com/blogs/author/amalraj-umapathy)

![Summary calculation of selected rows in WPF DataGrid](https://www.syncfusion.com/blogs/wp-content/uploads/2020/01/Summary-calculation-of-selected-rows-in-WPF-DataGrid-thegem-blog-justified.png)


We are happy to announce that in our [Essential Studio® 2019 Volume 4 release](https://www.syncfusion.com/forums/150001/essential-studio-2019-volume-4-release-v17-4-0-39-is-available-for-download)
, we added summary calculation support for selected rows in the [WPF DataGrid](https://www.syncfusion.com/wpf-ui-controls/datagrid)
 control. This blog provides a walk-through of how to calculate summaries for selected rows and how to use the available options.

The DataGrid allows users to calculate summaries for:

- Selected rows.
- All rows.
- All rows until rows are selected.

The [SummaryCalculationUnit](https://help.syncfusion.com/cr/wpf/Syncfusion.Data.SummaryCalculationUnit.html)
 enumeration is used to perform these operations.

To calculate a summary of selected rows in the DataGrid, set the [SfDataGrid.SummaryCalculationUnit](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Grid.SfDataGrid.html#Syncfusion_UI_Xaml_Grid_SfDataGrid_SummaryCalculationUnit)
 property to **SelectedRows**.

In the following example, a summary is calculated for group caption summary rows. This summary calculation support is also applicable for both group and table summary rows.

```
<syncfusion:SfDataGrid x:Name="sfDataGrid"                
                       AllowFrozenGroupHeaders="True"
                       AutoExpandGroups="True"
                       AutoGenerateColumns="False"
                       ColumnSizer="Auto"
                       SummaryCalculationUnit="SelectedRows"
                       ItemsSource="{Binding YearlySalesDetails}"
                       ShowColumnWhenGrouped="False"
                       SelectionMode="Multiple">
```

![Summary Calculation of Selected Rows in WPF DataGrid](https://www.syncfusion.com/blogs/wp-content/uploads/2020/01/Summary-Calculation-of-Selected-Rows-in-WPF-DataGrid.gif)A summary row can also be considered while calculating the summary.

```
<syncfusion:SfDataGrid.GroupSummaryRows>
    <syncfusion:GridSummaryRow Title="Total Sales in Year for selected products: {YearSales}" CalculationUnit="SelectedRows" ShowSummaryInRow="True">
        <syncfusion:GridSummaryRow.SummaryColumns>
            <syncfusion:GridSummaryColumn Name="YearSales"
                                          Format="'{Sum:c}'"
                                          MappingName="Total"
                                          SummaryType="DoubleAggregate" />
            <syncfusion:GridSummaryColumn Name="ProductCount"
                                          Format="'{Count:d}'"
                                          MappingName="Name"
                                          SummaryType="CountAggregate" />
        </syncfusion:GridSummaryRow.SummaryColumns>
    </syncfusion:GridSummaryRow>
</syncfusion:SfDataGrid.GroupSummaryRows>
```

![Summary calculation for selected rows with summary in WPF DataGrid](https://www.syncfusion.com/blogs/wp-content/uploads/2020/01/Summary-calculation-for-selected-rows-with-summary-in-WPF-DataGrid.gif)Here, let’s use the value for the property **SummaryCalculationUnit** of ** DataGrid** to calculate a summary of the selected rows; otherwise, the summary for all rows will be calculated.

I hope you now understand this feature and how to calculate summaries for selected rows in the WPF DataGrid. You can download a demo of calculating summaries for selected rows from our GitHub samples. To learn more about the summaries in the Syncfusion DataGrid, please refer to our [documentation](https://help.syncfusion.com/wpf/datagrid/summaries)
. You can download our [2019 Volume 4 release](https://www.syncfusion.com/forums/150001/essential-studio-2019-volume-4-release-v17-4-0-39-is-available-for-download)
 to check out all our new features and controls.

If you have any questions or require clarification for this control, please let us know in the comments section. You can also contact us through our [support forum](https://www.syncfusion.com/forums)
, [Direct-Trac](https://www.syncfusion.com/support/directtrac/)
, or [feedback portal](https://www.syncfusion.com/feedback/wpf)
. We are happy to assist you!
