# Numeric Display Format

Canonical page: https://www.adaptabletools.com/docs/handbook-column-formatting-display-format-number

- AdapTable provides a number of Display Formats to be used with Numeric Columns

AdapTable ships with a number of System Number Display Formats.

These are designed to provide Display Formats for numeric columns.

They are contained in the [`Number Formatter`](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md) object defined as follows:

| Property | Type | Description |
| --- | --- | --- |
| [Abs](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#abs) | `boolean` | Returns absolute value of cell value |
| [Ceiling](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#ceiling) | `boolean` | Returns smallest integer greater than cell value |
| [Content](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#content) | `string \| number` | Replaces cell value with supplied value (that can contain Template Literals) |
| [Empty](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#empty) | `boolean` | Show nothing in cell (but underlying value remains) |
| [Floor](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#floor) | `boolean` | Returns largest integer cell value |
| [FractionDigits](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#fractiondigits) | `number` | Number of digits to show in Fractions (up to 20) |
| [FractionSeparator](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#fractionseparator) | `string` | Separator to use in fractions |
| [IntegerDigits](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#integerdigits) | `number` | Number of digits to show for Integers (up to 20) |
| [IntegerSeparator](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#integerseparator) | `string` | Separator to use in Integers |
| [Multiplier](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#multiplier) | `number` | Multiplier to use on cell value |
| [Notation](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#notation) | `'standard' \| 'scientific'` | Numeric notation to use when rendering the value - standard or scientific |
| [Parentheses](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#parentheses) | `boolean` | Shows negative numbers in parentheses |
| [Prefix](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#prefix) | `string` | Prefix to use before cell value |
| [Round](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#round) | `boolean` | Rounds cell value |
| [Suffix](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#suffix) | `string` | Suffix to use after cell value |
| [Truncate](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#truncate) | `boolean` | Truncates cell value |
| [ZeroDisplay](https://www.adaptabletools.com/docs/reference/numberformatteroptions.md#zerodisplay) | `string` | What to show when numeric value is zero (after multiplier &amp; rounding) |

### Notation

Notation sets which of 2 notations to use for numeric cells:
- `'standard'` (default) — renders the number normally
- `'scientific'` — renders the number in scientific notation (e.g. `1.23e+5`)

When this value is selected `IntegerSeparator` is ignored and `FractionDigits` controls the number of mantissa digits

### Zero Display

The ZeroDisplay property sets what to display when a numeric value is zero (after multiplier & rounding).
- omitted / undefined /'0' — use normal formatting (e.g. `0`, `0.00`)
- `''` — show a blank cell (user cleared default `0` in wizard)
- any other string — show that text (e.g. `-`, `—`)

**Example: Column Formatting: Numeric Display Formats**

Column Formatting with Numeric Display Formats

- In this example 2 Format Columns use a full `NumberFormatter` object (not presets):
  - `Github Stars` — `Multiplier` `0.001` and suffix `K` (one decimal place)
  - `Issue Change` — negative values in **parentheses** via `Parentheses: true` (no fraction digits)

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: 'Numeric Display Format Options',
  initialState: {
    Dashboard: {
      ModuleButtons: ['FormatColumn'],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'name',
            'language',
            'github_stars',
            'week_issue_change',
            'closed_pr_count',
            'open_pr_count',
            'updated_at',
          ],
          AutoSizeColumns: true,
        },
      ],
    },
    FormatColumn: {
      FormatColumns: [
        {
          Name: 'formatColumn-github_stars',
          Scope: {
            ColumnIds: ['github_stars'],
          },
          DisplayFormat: {
            Formatter: 'NumberFormatter',
            Options: {
              FractionDigits: 1,
              FractionSeparator: '.',
              IntegerSeparator: ',',
              Multiplier: 0.001,
              Suffix: 'K',
            },
          },
        },
        {
          Name: 'formatColumn-week_issue_change',
          Scope: {
            ColumnIds: ['week_issue_change'],
          },
          DisplayFormat: {
            Formatter: 'NumberFormatter',
            Options: {
              FractionDigits: 0,
              FractionSeparator: '.',
              IntegerSeparator: ',',
              Parentheses: true,
            },
          },
        },
      ],
    },
  },
};
```

## Numeric Presets

AdapTable provides **15 preset numeric Display Formats** as a convenience feature.

These presets cover the most common use cases, and general-purpose number formats, out of the box, e.g. currency, magnitude, rate etc

Each preset is a short-hand name (e.g. `'Dollar'`, `'Percentage'`) containing a set of numeric format options.

- This allows you to specify the preset (e.g. `Dollar`) without supplying the details (e.g. `FractionDigits`, `Prefix`, etc.)
- AdapTable will convert the preset into a fully formed Display Format at runtime on your behalf

You can use a preset directly in Format Column Initial State, by simply assigning its name to `DisplayFormat`:

```ts
DisplayFormat: 'Dollar';
```

- You can later fall back to the long-form `NumberFormatter` object if you need to tweak any of the underlying options
- e.g. add a custom suffix, fraction digits, multiplier, etc.

### UI Wizard

The presets are also available in the Format Column [UI Wizard](https://www.adaptabletools.com/docs/ui-settings-panel-wizards/index.md).

This allows run-time users to create display formats quickly.

The wizard arranges the Presets into 4 groups: `Currencies`, `Magnitude`, `General Numeric` and `Specialised`.

The Presets provided by AdapTable are:

| Name (and UI Label) | Category    | Raw Value    | Display Format |
| ------------------- | ----------- | ------------ | -------------- |
| Dollar              | Currency    | `123.4567`   | `$123.46`      |
| Sterling            | Currency    | `123.4567`   | `£123.46`      |
| Euro                | Currency    | `123.4567`   | `€123.46`      |
| Yen                 | Currency    | `1234`       | `¥1,234`       |
| Bitcoin             | Currency    | `0.12345678` | `₿0.12345678`  |
| K (`Thousand`)      | Magnitude   | `123456`     | `123.456K`     |
| M (`Million`)       | Magnitude   | `123456789`  | `123.456789M`  |
| B (`Billion`)       | Magnitude   | `1234567890` | `1.23456789B`  |
| Integer             | General     | `1234.56`    | `1,235`        |
| Decimal             | General     | `1234.5678`  | `1,234.57`     |
| Percentage          | General     | `0.54321`    | `54.32%`       |
| Scientific          | General     | `1234567`    | `1.23E6`       |
| Accounting          | Specialised | `-1234.56`   | `(1,234.56)`   |
| FX Rate (`FXRate`)  | Specialised | `1.23456`    | `1.2346`       |
| bps (`BasisPoints`) | Specialised | `0.0125`     | `125 bps`      |

- **Accounting** prints negative numbers in parentheses (positives render plain) — a long-standing finance convention
- **Basis Points** assumes the raw value is a decimal rate (1 = 100%), multiplies by `10000` and appends ` bps`
- **Scientific** uses JavaScript's `Intl.NumberFormat` with `notation: 'scientific'`, capped to 2 fraction digits

**Example: Column Formatting: Numeric Display Format Presets**

Column Formatting with Numeric Display Format Presets

- In this example, 3 Format Columns have `DisplayFormat` set to a **preset name** directly (AdapTable resolves these at runtime):
  - `Open/Total Issues` — `'Percentage'` (calculated ratio column)
  - `Issue Change` — `'Accounting'` (negatives in parentheses)
  - `Github Stars` — `'Thousand'` (values shown in thousands with a `K` suffix)

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: 'Numeric Display Format Presets',
  initialState: {
    Dashboard: {
      ModuleButtons: ['FormatColumn'],
    },
    Theme: {CurrentTheme: 'dark'},
    Layout: {
      CurrentLayout: 'Standard Layout',
      Layouts: [
        {
          Name: 'Standard Layout',
          TableColumns: [
            'name',
            'language',
            'open-total-issue-ratio',
            'github_stars',
            'week_issue_change',
            'closed_pr_count',
            'updated_at',
          ],
          AutoSizeColumns: true,
        },
      ],
    },
    FormatColumn: {
      FormatColumns: [
        {
          Name: 'formatColumn-open-total-issue-ratio',
          Scope: {
            ColumnIds: ['open-total-issue-ratio'],
          },
          DisplayFormat: 'Percentage',
        },
        {
          Name: 'formatColumn-week_issue_change',
          Scope: {
            ColumnIds: ['week_issue_change'],
          },
          DisplayFormat: 'Accounting',
        },
        {
          Name: 'formatColumn-github_stars',
          Scope: {
            ColumnIds: ['github_stars'],
          },
          DisplayFormat: 'Thousand',
        },
      ],
    },
    CalculatedColumn: {
      CalculatedColumns: [
        {
          ColumnId: 'open-total-issue-ratio',
          Expression: '[open_pr_count]/([open_pr_count]+[closed_pr_count])',
          CalculatedColumnSettings: {
            DataType: 'number',
          },
          FriendlyName: 'Open/Total Issues',
        },
      ],
    },
  },
};
```

### FAQ

**Can we show a currency symbol?**
Yes. Use a preset such as `'Dollar'`, `'Sterling'`, or `'Euro'`, or set `Prefix` / `Suffix` on a `NumberFormatter`.

**Can negative numbers appear in parentheses?**
Yes. Use the `'Accounting'` preset, or set `Parentheses: true` on a `NumberFormatter`.

**Can we show percentages?**
Yes. Use the `'Percentage'` preset (expects a decimal rate, e.g. `0.54` → `54%`), or set `Multiplier: 100` and `Suffix: '%'` yourself.

**Can we show large numbers as K / M / B?**
Yes. Use `'Thousand'`, `'Million'`, or `'Billion'`, or set `Multiplier` and `Suffix` manually (see the [options demo](https://www.adaptabletools.com/docs/handbook-column-formatting-display-format-number/index.md) above).

**If we show no fraction digits, does AdapTable round?**
Yes. For example, `11.87` with `FractionDigits: 0` displays as `12`.

**When is a preset not enough?**
Use a full `NumberFormatter` when you need a mix the presets do not provide — for example `Prefix: '≈ '`, `Multiplier: 0.01`, `Suffix: ' pts'`, and `FractionDigits: 1` on the same column.
