# Summarising Grid Data

Canonical page: https://www.adaptabletools.com/docs/handbook-summarising

- AdapTable offers two ways to see summary information for AG Grid data:
  - **Cell Summaries** — comprehensive summaries of the currently selected cells in numeric columns
  - **Row Summaries** — layout-based pinned rows that show per-column aggregations over the grid 

AdapTable can summarise AG Grid data through [Cell Summaries](https://www.adaptabletools.com/docs/handbook-summarising-cells/index.md) and [Row Summaries](https://www.adaptabletools.com/docs/handbook-summarising-rows/index.md):

<section className="my-8 sm:my-10 grid grid-cols-1 lg:grid-cols-2 gap-x-8 gap-y-4">
  <div className="flex flex-col justify-center">
        
    </div>  
  <div className="flex flex-col justify-center">
       
    </div>  
</section>

**Example: Summarising Grid Data**

Summarising Grid Data in AdapTable

- This example demonstrates summarising in AdapTable:
  - **Cell Summary**: we select a cell range in `Github Stars` column (using AdapTable's [Grid API](https://www.adaptabletools.com/docs/handbook-managing-grid-data/index.md)) and display the Sum of the values in the Cell Summary UI components
  - **Row Summary**: we provide a Row Summary (at the top) showing aggregations for 4 Columns

- Select different cell ranges and different Summary Operations in the `Cell Summary` dashboard and see the results
- Alternatively right-click and select Cell Summary to open the Cell Summary page in the [Settings Panel](https://www.adaptabletools.com/docs/ui-settings-panel/index.md)
- Edit some cell value in the numeric columns and see the Summaries update

Demo project (Vanilla); the files without a marker are shown below:

```text
src/
  adaptableOptions.ts
  agGridModules.ts     [template]
  columnDefs.ts        [template]
  gridOptions.ts       [template]
  index.ts             [template]
  onAdaptableReady.ts
  rowData.ts           [template]
  styles.css           [template]
index.html             [template]
package.json           [template]
tsconfig.json          [template]
```

Files marked `[template]` are the same in every demo; see the [demo template](https://www.adaptabletools.com/llms/demo-template.md#vanilla).

**`src/adaptableOptions.ts`**

```ts
import {AdaptableOptions} from '@adaptabletools/adaptable';
import {WebFramework} from './rowData';

export const adaptableOptions: AdaptableOptions<WebFramework> = {
  primaryKey: 'id',
  adaptableId: 'Summarising Grid Data',
  initialState: {
    Dashboard: {
      ModuleButtons: ['CellSummary'],
      Tabs: [
        {
          Name: 'Default',
          Toolbars: ['CellSummary', 'Layout'],
        },
      ],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['CellSummary', 'Layout'],
        },
      ],
    },
    FormatColumn: {
      FormatColumns: [
        {
          Name: 'formatColumn-github_stars',
          Scope: {
            ColumnIds: ['github_stars'],
          },
          DisplayFormat: {
            Formatter: 'NumberFormatter',
            Options: {
              FractionDigits: 0,
            },
          },
        },
      ],
    },
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          TableColumns: [
            'name',
            'language',
            'week_issue_change',
            'github_stars',
            'github_watchers',
            'license',
            'created_at',
            'has_wiki',
            'updated_at',
            'pushed_at',
            'open_issues_count',
            'closed_issues_count',
            'open_pr_count',
            'closed_pr_count',
            'has_projects',
            'has_pages',
          ],
          RowSummaries: [
            {
              Position: 'Top',
              ColumnsMap: {
                github_watchers: 'SUM',
                week_issue_change: 'AVG',
                github_stars: 'SUM',
                language: 'COUNT',
              },
            },
          ],
          Name: 'Standard Layout',
          AutoSizeColumns: true,
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
  },
};
```

**`src/onAdaptableReady.ts`**

```ts
import {AdaptableReadyInfo, GridCellRange} from '@adaptabletools/adaptable';

export const onAdaptableReady = ({adaptableApi}: AdaptableReadyInfo) => {
  adaptableApi.toolPanelApi.openAdapTableToolPanel();

  setTimeout(() => {
    const gridCellRange: GridCellRange = {
      columnIds: ['github_stars'],
      rowIndexStart: 0,
      rowIndexEnd: 5,
    };
    adaptableApi.gridApi.selectCellRange(gridCellRange);
    adaptableApi.toolPanelApi.setAdaptableToolPanelVisibilityMode(
      'CellSummary',
      'expanded'
    );
  }, 200);
};
```

Cell summaries require **cell selection** (`CellSelection` module and `cellSelection` in grid options); see [Selecting Grid Data](https://www.adaptabletools.com/docs/handbook-selecting/index.md). Row summaries are part of **table layout** state; see [Table Layouts](https://www.adaptabletools.com/docs/handbook-layouts-table/index.md) and [Summarising Technical Reference](https://www.adaptabletools.com/docs/technical-reference-summarising/index.md).
