---
title: "Aggregation - Filtering"
enterprise: true
framework: angular
version: "36.1.0"
---

# Aggregation - Filtering

Filtering can be configured to impact aggregate values in the grid.

## Ignore Filters when Aggregating

When using [Filters](https://www.ag-grid.com/angular-data-grid/filtering-overview/) and [Aggregations](https://www.ag-grid.com/angular-data-grid/aggregation/) together, the aggregated values reflect only the rows which have passed the filter. This can be changed to instead ignore applied filters by using the `suppressAggFilteredOnly` grid option.

#### Aggregation and Filters

```ts
import { Component } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { AgGridAngular } from "ag-grid-angular";
import "./styles.css";
import {
  AutoGroupColumnDef,
  ClientSideRowModelModule,
  ColDef,
  ColGroupDef,
  GridApi,
  GridOptions,
  GridReadyEvent,
  ModuleRegistry,
  NumberFilterModule,
  TextFilterModule,
  UseGroupTotalRow,
  enableDevValidations,
} from "ag-grid-community";
import { RowGroupingModule } from "ag-grid-enterprise";
if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

ModuleRegistry.registerModules([
  NumberFilterModule,
  ClientSideRowModelModule,
  RowGroupingModule,
  TextFilterModule,
]);

@Component({
  selector: "my-app",
  standalone: true,
  imports: [AgGridAngular],
  template: `<div class="example-wrapper">
    <div class="example-header">
      <label>
        <span>suppressAggFilteredOnly:</span>
        <input
          id="suppressAggFilteredOnly"
          type="checkbox"
          (change)="toggleProperty()"
        />
      </label>
    </div>
    <ag-grid-angular
      style="width: 100%; height: 100%;"
      [columnDefs]="columnDefs"
      [defaultColDef]="defaultColDef"
      [autoGroupColumnDef]="autoGroupColumnDef"
      [groupTotalRow]="groupTotalRow"
      [rowData]="rowData"
      (gridReady)="onGridReady($event)"
    />
  </div> `,
})
export class AppComponent {
  private gridApi!: GridApi;

  columnDefs: ColDef[] = [
    { field: "country", rowGroup: true, hide: true },
    { field: "year", rowGroup: true, hide: true },
    { field: "sport", filter: "agTextColumnFilter", floatingFilter: true },
    { field: "gold", aggFunc: "sum" },
    { field: "silver", aggFunc: "sum" },
    { field: "bronze", aggFunc: "sum" },
  ];
  defaultColDef: ColDef = {
    flex: 1,
    minWidth: 150,
  };
  autoGroupColumnDef: AutoGroupColumnDef = {
    minWidth: 300,
  };
  groupTotalRow: "top" | "bottom" | UseGroupTotalRow = "bottom";
  rowData!: any[];

  constructor(private http: HttpClient) {}

  toggleProperty() {
    const enable = document.querySelector<HTMLInputElement>(
      "#suppressAggFilteredOnly",
    )!.checked;
    this.gridApi.setGridOption("suppressAggFilteredOnly", enable);
  }

  onGridReady(params: GridReadyEvent) {
    this.gridApi = params.api;

    params.api.setFilterModel({
      sport: {
        type: "contains",
        filter: "Swimming",
      },
    });

    this.http
      .get<any[]>("https://www.ag-grid.com/example-assets/olympic-winners.json")
      .subscribe((data) => (this.rowData = data));
  }
}
```

[Live example: Aggregation and Filters](https://www.ag-grid.com/examples/aggregation-filtering/filters/angular)

The example above demonstrates the impact of the `suppressAggFilteredOnly` grid option. This can be enabled as shown:

```ts
<ag-grid-angular
    [suppressAggFilteredOnly]="suppressAggFilteredOnly"
    /* other grid options ... */ />

this.suppressAggFilteredOnly = true;
```

## Filtering for Aggregated Values

The grid only applies filters to leaf level rows, this can be toggled to instead also apply filtering to group rows by enabling the `groupAggFiltering` grid option, allowing filters to also apply against the aggregated values.

#### Group and Leaf Aggregate Filtering

```ts
import { Component } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { AgGridAngular } from "ag-grid-angular";
import "./styles.css";
import {
  AutoGroupColumnDef,
  ClientSideRowModelModule,
  ColDef,
  ColGroupDef,
  GridApi,
  GridOptions,
  GridReadyEvent,
  IsRowFilterable,
  ModuleRegistry,
  NumberFilterModule,
  enableDevValidations,
} from "ag-grid-community";
import {
  ColumnMenuModule,
  ContextMenuModule,
  RowGroupingModule,
  SetFilterModule,
} from "ag-grid-enterprise";
if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

ModuleRegistry.registerModules([
  ClientSideRowModelModule,
  ColumnMenuModule,
  ContextMenuModule,
  RowGroupingModule,
  SetFilterModule,
  NumberFilterModule,
]);

@Component({
  selector: "my-app",
  standalone: true,
  imports: [AgGridAngular],
  template: `<div class="example-wrapper">
    <div class="example-header">
      <label>
        <span>groupAggFiltering:</span>
        <input
          id="groupAggFiltering"
          type="checkbox"
          (change)="toggleProperty()"
        />
      </label>
    </div>
    <ag-grid-angular
      style="width: 100%; height: 100%;"
      [columnDefs]="columnDefs"
      [defaultColDef]="defaultColDef"
      [autoGroupColumnDef]="autoGroupColumnDef"
      [groupDefaultExpanded]="groupDefaultExpanded"
      [groupAggFiltering]="true"
      [rowData]="rowData"
      (gridReady)="onGridReady($event)"
    />
  </div> `,
})
export class AppComponent {
  private gridApi!: GridApi;

  columnDefs: ColDef[] = [
    { field: "country", rowGroup: true, hide: true },
    { field: "year" },
    { field: "total", aggFunc: "sum", filter: "agNumberColumnFilter" },
  ];
  defaultColDef: ColDef = {
    flex: 1,
    floatingFilter: true,
  };
  autoGroupColumnDef: AutoGroupColumnDef = {
    field: "athlete",
  };
  groupDefaultExpanded = -1;
  rowData!: any[];

  constructor(private http: HttpClient) {}

  toggleProperty() {
    const enable =
      document.querySelector<HTMLInputElement>("#groupAggFiltering")!.checked;
    this.gridApi.setGridOption("groupAggFiltering", enable);
  }

  onGridReady(params: GridReadyEvent) {
    this.gridApi = params.api;

    document.querySelector<HTMLInputElement>("#groupAggFiltering")!.checked =
      true;
    params.api.setFilterModel({
      total: {
        type: "contains",
        filter: "192",
      },
    });

    this.http
      .get<any[]>("https://www.ag-grid.com/example-assets/olympic-winners.json")
      .subscribe((data) => (this.rowData = data));
  }
}
```

[Live example: Group and Leaf Aggregate Filtering](https://www.ag-grid.com/examples/aggregation-filtering/agg-filtering-all/angular)

> **Note**
>
> Take note of the following while using `groupAggFiltering`:
>
> - When a group row passes a filter, it also includes all of its descendent rows in the filtered results.
> - The `suppressAggFilteredOnly` grid option will be implicitly enabled.
> - [Set Filters](https://www.ag-grid.com/angular-data-grid/filter-set/) will only work with leaf rows.

The following configuration demonstrates how to enable group aggregation filtering:

```ts
<ag-grid-angular
    [groupAggFiltering]="groupAggFiltering"
    /* other grid options ... */ />

this.groupAggFiltering = true;
```

### Configure by Callback

When filtering for aggregated values the filter applies to all group rows by default. This can be configured more granularly by instead providing the `groupAggFiltering` grid option with a callback function.

The example below demonstrates a grid configured to apply filters only to aggregated values, and not the leaf rows:

#### Group-Only Aggregate Filtering

```ts
import { Component } from "@angular/core";
import { HttpClient } from "@angular/common/http";
import { AgGridAngular } from "ag-grid-angular";
import {
  AutoGroupColumnDef,
  ClientSideRowModelModule,
  ColDef,
  ColGroupDef,
  GridApi,
  GridOptions,
  GridReadyEvent,
  IsRowFilterable,
  ModuleRegistry,
  NumberFilterModule,
  TextFilterModule,
  enableDevValidations,
} from "ag-grid-community";
import {
  ColumnMenuModule,
  ContextMenuModule,
  RowGroupingModule,
} from "ag-grid-enterprise";
if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

ModuleRegistry.registerModules([
  TextFilterModule,
  ClientSideRowModelModule,
  ColumnMenuModule,
  ContextMenuModule,
  RowGroupingModule,
  NumberFilterModule,
]);

@Component({
  selector: "my-app",
  standalone: true,
  imports: [AgGridAngular],
  template: `<ag-grid-angular
    style="width: 100%; height: 100%;"
    [columnDefs]="columnDefs"
    [defaultColDef]="defaultColDef"
    [autoGroupColumnDef]="autoGroupColumnDef"
    [groupDefaultExpanded]="groupDefaultExpanded"
    [groupAggFiltering]="groupAggFiltering"
    [rowData]="rowData"
    (gridReady)="onGridReady($event)"
  /> `,
})
export class AppComponent {
  columnDefs: ColDef[] = [
    { field: "country", rowGroup: true, hide: true },
    { field: "year" },
    { field: "total", aggFunc: "sum", filter: "agNumberColumnFilter" },
  ];
  defaultColDef: ColDef = {
    flex: 1,
    floatingFilter: true,
  };
  autoGroupColumnDef: AutoGroupColumnDef = {
    field: "athlete",
  };
  groupDefaultExpanded = -1;
  groupAggFiltering: boolean | IsRowFilterable = (params) =>
    !!params.node.group;
  rowData!: any[];

  constructor(private http: HttpClient) {}

  onGridReady(params: GridReadyEvent) {
    this.http
      .get<any[]>("https://www.ag-grid.com/example-assets/olympic-winners.json")
      .subscribe((data) => (this.rowData = data));
  }
}
```

[Live example: Group-Only Aggregate Filtering](https://www.ag-grid.com/examples/aggregation-filtering/agg-filtering-group/angular)

The configuration below demonstrates how to only apply test filters against group rows, and not leaf rows:

```ts
<ag-grid-angular
    [groupAggFiltering]="groupAggFiltering"
    /* other grid options ... */ />

this.groupAggFiltering = (params) => !!params.node.group;
```
