---
title: "Aggregation - Filtering"
enterprise: true
framework: vue
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/vue-data-grid/filtering-overview/) and [Aggregations](https://www.ag-grid.com/vue-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 {
  createApp,
  defineComponent,
  onBeforeMount,
  ref,
  shallowRef,
} from "vue";
import { AgGridVue } from "ag-grid-vue3";
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,
]);

const VueExample = defineComponent({
  template: `
        <div style="height: 100%">
                <div class="example-wrapper">
      <div class="example-header">
        <label>
          <span>suppressAggFilteredOnly:</span>
          <input id="suppressAggFilteredOnly" type="checkbox" v-on:change="toggleProperty()">
          </label>
        </div>
        <ag-grid-vue
          style="width: 100%; height: 100%;"
          @grid-ready="onGridReady"
          :columnDefs="columnDefs"
          :defaultColDef="defaultColDef"
          :autoGroupColumnDef="autoGroupColumnDef"
          :groupTotalRow="groupTotalRow"
          :rowData="rowData"></ag-grid-vue>
        </div>
        </div>
    `,
  components: {
    "ag-grid-vue": AgGridVue,
  },
  setup(props) {
    const gridApi = shallowRef<GridApi | null>(null);
    const columnDefs = ref<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" },
    ]);
    const defaultColDef = ref<ColDef>({
      flex: 1,
      minWidth: 150,
    });
    const autoGroupColumnDef = ref<AutoGroupColumnDef>({
      minWidth: 300,
    });
    const groupTotalRow = ref<"top" | "bottom" | UseGroupTotalRow>("bottom");
    const rowData = ref<any[]>(null);

    function toggleProperty() {
      const enable = document.querySelector<HTMLInputElement>(
        "#suppressAggFilteredOnly",
      )!.checked;
      gridApi.value.setGridOption("suppressAggFilteredOnly", enable);
    }
    const onGridReady = (params: GridReadyEvent) => {
      gridApi.value = params.api;

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

      const updateData = (data) => (rowData.value = data);

      fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
        .then((resp) => resp.json())
        .then((data) => updateData(data));
    };

    return {
      gridApi,
      columnDefs,
      defaultColDef,
      autoGroupColumnDef,
      groupTotalRow,
      rowData,
      onGridReady,
      toggleProperty,
    };
  },
});

const app = createApp(VueExample);
app.mount("#app");
```

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

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

```ts
<ag-grid-vue
    :suppressAggFilteredOnly="suppressAggFilteredOnly"
    /* other grid options ... */>
</ag-grid-vue>

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 {
  createApp,
  defineComponent,
  onBeforeMount,
  ref,
  shallowRef,
} from "vue";
import { AgGridVue } from "ag-grid-vue3";
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,
]);

const VueExample = defineComponent({
  template: `
        <div style="height: 100%">
                <div class="example-wrapper">
      <div class="example-header">
        <label>
          <span>groupAggFiltering:</span>
          <input id="groupAggFiltering" type="checkbox" v-on:change="toggleProperty()">
          </label>
        </div>
        <ag-grid-vue
          style="width: 100%; height: 100%;"
          @grid-ready="onGridReady"
          :columnDefs="columnDefs"
          :defaultColDef="defaultColDef"
          :autoGroupColumnDef="autoGroupColumnDef"
          :groupDefaultExpanded="groupDefaultExpanded"
          :groupAggFiltering="true"
          :rowData="rowData"></ag-grid-vue>
        </div>
        </div>
    `,
  components: {
    "ag-grid-vue": AgGridVue,
  },
  setup(props) {
    const gridApi = shallowRef<GridApi | null>(null);
    const columnDefs = ref<ColDef[]>([
      { field: "country", rowGroup: true, hide: true },
      { field: "year" },
      { field: "total", aggFunc: "sum", filter: "agNumberColumnFilter" },
    ]);
    const defaultColDef = ref<ColDef>({
      flex: 1,
      floatingFilter: true,
    });
    const autoGroupColumnDef = ref<AutoGroupColumnDef>({
      field: "athlete",
    });
    const groupDefaultExpanded = ref(-1);
    const rowData = ref<any[]>(null);

    function toggleProperty() {
      const enable =
        document.querySelector<HTMLInputElement>("#groupAggFiltering")!.checked;
      gridApi.value.setGridOption("groupAggFiltering", enable);
    }
    const onGridReady = (params: GridReadyEvent) => {
      gridApi.value = params.api;

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

      const updateData = (data) => (rowData.value = data);

      fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
        .then((resp) => resp.json())
        .then((data) => updateData(data));
    };

    return {
      gridApi,
      columnDefs,
      defaultColDef,
      autoGroupColumnDef,
      groupDefaultExpanded,
      rowData,
      onGridReady,
      toggleProperty,
    };
  },
});

const app = createApp(VueExample);
app.mount("#app");
```

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

> **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/vue-data-grid/filter-set/) will only work with leaf rows.

The following configuration demonstrates how to enable group aggregation filtering:

```ts
<ag-grid-vue
    :groupAggFiltering="groupAggFiltering"
    /* other grid options ... */>
</ag-grid-vue>

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 {
  createApp,
  defineComponent,
  onBeforeMount,
  ref,
  shallowRef,
} from "vue";
import { AgGridVue } from "ag-grid-vue3";
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,
]);

const VueExample = defineComponent({
  template: `
        <div style="height: 100%">
                <ag-grid-vue
      style="width: 100%; height: 100%;"
      @grid-ready="onGridReady"
      :columnDefs="columnDefs"
      :defaultColDef="defaultColDef"
      :autoGroupColumnDef="autoGroupColumnDef"
      :groupDefaultExpanded="groupDefaultExpanded"
      :groupAggFiltering="groupAggFiltering"
      :rowData="rowData"></ag-grid-vue>
        </div>
    `,
  components: {
    "ag-grid-vue": AgGridVue,
  },
  setup(props) {
    const gridApi = shallowRef<GridApi | null>(null);
    const columnDefs = ref<ColDef[]>([
      { field: "country", rowGroup: true, hide: true },
      { field: "year" },
      { field: "total", aggFunc: "sum", filter: "agNumberColumnFilter" },
    ]);
    const defaultColDef = ref<ColDef>({
      flex: 1,
      floatingFilter: true,
    });
    const autoGroupColumnDef = ref<AutoGroupColumnDef>({
      field: "athlete",
    });
    const groupDefaultExpanded = ref(-1);
    const groupAggFiltering = ref<boolean | IsRowFilterable>(
      (params) => !!params.node.group,
    );
    const rowData = ref<any[]>(null);

    const onGridReady = (params: GridReadyEvent) => {
      gridApi.value = params.api;

      const updateData = (data) => (rowData.value = data);

      fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
        .then((resp) => resp.json())
        .then((data) => updateData(data));
    };

    return {
      gridApi,
      columnDefs,
      defaultColDef,
      autoGroupColumnDef,
      groupDefaultExpanded,
      groupAggFiltering,
      rowData,
      onGridReady,
    };
  },
});

const app = createApp(VueExample);
app.mount("#app");
```

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

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

```ts
<ag-grid-vue
    :groupAggFiltering="groupAggFiltering"
    /* other grid options ... */>
</ag-grid-vue>

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