# AnalyticsCalculation Interface

> AnalyticsCalculation interface in the TX Sheet Control TypeScript API for the browser, with its syntax and a TypeScript example.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Interface
- **Path:** TX Sheet Control > API Reference > TypeScript API > Browser Editor > AnalyticsCalculation Interface
- **1243 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/analyticscalculation/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/analyticscalculation/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/analyticscalculation/llms-full.txt

---

A bounded, deterministic arithmetic or ordered-window calculation on grouped query results. Window operations follow query.sort order. Division by zero and missing numeric operands produce null.

Package: `@txtextcontrol/tx-sheet-control`. This is a settings/result contract, not a runtime constructor.

### Members

| Property | Description |
|---|---|
| [alias](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/analyticscalculation/alias-property/llms-full.txt) | Configures alias on AnalyticsCalculation; apply the complete settings object through its owning dashboard. |
| [operation](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/analyticscalculation/operation-property/llms-full.txt) | Configures operation on AnalyticsCalculation; apply the complete settings object through its owning dashboard. |
| [left](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/analyticscalculation/left-property/llms-full.txt) | Configures left on AnalyticsCalculation; apply the complete settings object through its owning dashboard. |
| [right](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/analyticscalculation/right-property/llms-full.txt) | Configures right on AnalyticsCalculation; apply the complete settings object through its owning dashboard. |
| [window](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/analyticscalculation/window-property/llms-full.txt) | Moving-average trailing window length, 1..1000; defaults to 3. |

### Examples

Configure a complete sales dashboard using this contract. Pass the workbook from your existing editor or server control.

```typescript
import type { Workbook, AnalyticsCalculation } from '@txtextcontrol/tx-sheet-control';

async function configureSalesDashboard(book: Workbook) {
    const sheet = book.sheets.at(0);
    sheet.range('A1:G5').setValues([
        ['Region', 'Country', 'Customer', 'Revenue', 'Profit', 'Date', 'Units'],
        ['Europe', 'Germany', 'Studio', 42000, 12000, '2026-01-15', 12],
        ['Europe', 'France', 'Labs', 38000, 9000, '2026-02-15', 15],
        ['Americas', 'Canada', 'Partners', 31000, 8000, '2026-01-15', 9],
        ['Americas', 'United States', 'Design', 49000, 15000, '2026-02-15', 18]
    ]);
    book.analytics.setSource({ id: 'sales', name: 'Sales', sheetId: sheet.id, range: 'A1:G5', hasHeaderRow: true });
    const dashboard = book.dashboards.add('Sales Performance');
    dashboard.update({ sections: [{ id: 'summary', title: 'Executive Summary' }] });
    dashboard.addWidget({
        id: 'revenue', type: 'column', title: 'Regional Revenue',
        placement: { x: 0, y: 0, width: 8, height: 6 },
        query: { sourceId: 'sales', dimensions: ['Region'], measures: [
            { field: 'Revenue', aggregation: 'SUM', alias: 'Revenue' },
            { field: 'Profit', aggregation: 'SUM', alias: 'Profit' }
        ] }
    });
    const settings: AnalyticsCalculation = {
        "alias": "Margin",
        "operation": "divide",
        "left": "Profit",
        "right": "Revenue",
        "window": 3
    };
    dashboard.updateWidget('revenue', { query: { ...dashboard.snapshot.widgets[0].query!, calculations: [settings] }, chart: { yField: 'Margin' } });
    book.activeView = { type: 'dashboard', id: dashboard.id };
}
```

---

## In This Section

- [AnalyticsCalculation.alias Property](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/analyticscalculation/alias-property/llms-full.txt): AnalyticsCalculation.alias property in the TX Sheet Control TypeScript API for the browser, with its type string and a TypeScript example.
- [AnalyticsCalculation.left Property](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/analyticscalculation/left-property/llms-full.txt): AnalyticsCalculation.left property in the TX Sheet Control TypeScript API for the browser, with its type string and a TypeScript example.
- [AnalyticsCalculation.operation Property](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/analyticscalculation/operation-property/llms-full.txt): AnalyticsCalculation.operation property in the TX Sheet Control TypeScript API for the browser, with its type | 'add' and a TypeScript example.
- [AnalyticsCalculation.right Property](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/analyticscalculation/right-property/llms-full.txt): AnalyticsCalculation.right property in the TX Sheet Control TypeScript API for the browser, with its type string and a TypeScript example.
- [AnalyticsCalculation.window Property](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/analyticscalculation/window-property/llms-full.txt): AnalyticsCalculation.window property in the TX Sheet Control TypeScript API for the browser: Moving-average trailing window length, 1..1000; defaults to 3.

---

## Nearby

- **Previous:** [XlsxWarning.part Property](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/xlsxwarning/part-property/llms-full.txt)
- **Next:** [AnalyticsCalculation.alias Property](https://docs.textcontrol.com/tx-sheet-control/reference/typescript-api/browser/analyticscalculation/alias-property/llms-full.txt)
