# Formatting Aggregations

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

- Aggregated Cells can be formatted and styled (including by using Conditions)
- It is possible to configure the formatting so that only the grouped (and not data) rows are formatted

AdapTable allows users to [format and style](https://www.adaptabletools.com/docs/handbook-column-formatting/index.md) aggregated cells in a grouped row.

It is also possible to format Grand Total Rows - see [Grand Total Rows: Formatting](https://www.adaptabletools.com/docs/handbook-aggregation-grand-total-row/index.md#formatting) for more information

This is done in exactly the same way as a data row, meaning it is also possible to create [Conditional Styles](https://www.adaptabletools.com/docs/handbook-column-formatting-conditions/index.md).

- It is possible to set formatting so that **only** the aggregated values are formatted
- This is done by setting the `RowScope` property to `ExcludeDataRows` in the Format Definition (or Format Wizard)

**Example: Aggregations: Formatting**

Formatting and Styling Aggregations

- In this example we have provided a [Format Column](https://www.adaptabletools.com/docs/handbook-column-formatting/index.md) of light blue and bold to the `Github Stars` and `Github Watchers` Columns with 2 features:
  - We set it only to display in Grouped Rows (by excluding Data Rows)
  - We added a condition of >3000 (which is why `Github Watchers` in _HTML_ row doesnt display the style)

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  [template]
  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: 'Formatting Agg Funcs',
  initialState: {
    Dashboard: {
      Tabs: [{Name: 'Demo', Toolbars: ['Layout']}],
    },
    StatusBar: {
      StatusBars: [
        {
          Key: 'Center Panel',
          StatusBarPanels: ['Layout'],
        },
      ],
    },
    Theme: {CurrentTheme: 'dark'},
    FormatColumn: {
      FormatColumns: [
        {
          Name: 'formatColumn-github_stars',
          Scope: {ColumnIds: ['github_stars', 'github_watchers']},
          Rule: '$SCOPE > 3000',
          Style: {
            ForeColor: 'Pink',
            FontWeight: 'Bold',
          },
          RowScope: {
            ExcludeDataRows: true,
          },
        },
      ],
    },
    Layout: {
      CurrentLayout: 'Grouped Layout',
      Layouts: [
        {
          Name: 'Grouped Layout',
          RowGroupedColumns: ['language'],
          TableAggregationColumns: [
            {
              ColumnId: 'github_watchers',
              AggFunc: 'sum',
            },
            {
              ColumnId: 'github_stars',
              AggFunc: 'sum',
            },
          ],
          TableColumns: [
            'name',
            'github_stars',
            'language',
            'github_watchers',
            'updated_at',
            'license',
            'created_at',
          ],
          AutoSizeColumns: true,
        },
      ],
    },
  },
};
```
