# AnalyticsQuery Interface

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

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Interface
- **Path:** TX Sheet Control > API Reference > JavaScript API > Browser Editor > AnalyticsQuery Interface
- **2014 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/llms-full.txt

---

Bounded, deterministic query. Joined columns use targetSourceId.fieldId. Sorting ties preserve source order.

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

### Members

| Property | Description |
|---|---|
| [sourceId](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/sourceid-property/llms-full.txt) | Configures sourceId on AnalyticsQuery; apply the complete settings object through its owning dashboard. |
| [dimensions](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/dimensions-property/llms-full.txt) | Configures dimensions on AnalyticsQuery; apply the complete settings object through its owning dashboard. |
| [measures](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/measures-property/llms-full.txt) | Configures measures on AnalyticsQuery; apply the complete settings object through its owning dashboard. |
| [calculations](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/calculations-property/llms-full.txt) | Explicit arithmetic on aggregated aliases; missing operands remain null. |
| [dateGrouping](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/dategrouping-property/llms-full.txt) | Calendar grouping is applied to dimensions before aggregation; worksheet values are unchanged. |
| [parameters](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/parameters-property/llms-full.txt) | Numeric parameter defaults referenced by calculation operands with an at-sign prefix, such as `@growth`; dashboard parameters override query defaults. |
| [topN](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/topn-property/llms-full.txt) | Retains the highest/lowest groups and optionally aggregates all remaining groups into Other. |
| [filters](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/filters-property/llms-full.txt) | Configures filters on AnalyticsQuery; apply the complete settings object through its owning dashboard. |
| [relationshipIds](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/relationshipids-property/llms-full.txt) | Configures relationshipIds on AnalyticsQuery; apply the complete settings object through its owning dashboard. |
| [sort](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/sort-property/llms-full.txt) | Configures sort on AnalyticsQuery; apply the complete settings object through its owning dashboard. |
| [limit](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/limit-property/llms-full.txt) | Configures limit on AnalyticsQuery; apply the complete settings object through its owning dashboard. |

### Examples

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

```javascript
async function configureSalesDashboard(book) {
    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 = {
        "sourceId": "sales",
        "dimensions": [
            "Region"
        ],
        "measures": [
            {
                "field": "Revenue",
                "aggregation": "SUM",
                "alias": "Revenue"
            },
            {
                "field": "Profit",
                "aggregation": "SUM",
                "alias": "Profit"
            }
        ],
        "parameters": {
            "growth": 1.1
        },
        "calculations": [
            {
                "alias": "Forecast",
                "operation": "multiply",
                "left": "Revenue",
                "right": "@growth"
            }
        ],
        "topN": {
            "count": 5,
            "field": "Revenue",
            "descending": true,
            "includeOther": true,
            "label": "Other"
        },
        "sort": {
            "field": "Revenue",
            "descending": true
        },
        "limit": 100
    };
    dashboard.updateWidget('revenue', { query: settings });
    book.activeView = { type: 'dashboard', id: dashboard.id };
}
```

---

## In This Section

- [AnalyticsQuery.calculations Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/calculations-property/llms-full.txt): AnalyticsQuery.calculations property in the TX Sheet Control JavaScript API for the browser, with its type AnalyticsCalculation[] and a JavaScript example.
- [AnalyticsQuery.dateGrouping Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/dategrouping-property/llms-full.txt): AnalyticsQuery.dateGrouping property in the TX Sheet Control JavaScript API for the browser, with its syntax and a JavaScript example.
- [AnalyticsQuery.dimensions Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/dimensions-property/llms-full.txt): AnalyticsQuery.dimensions property in the TX Sheet Control JavaScript API for the browser, with its type string[] and a JavaScript example.
- [AnalyticsQuery.filters Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/filters-property/llms-full.txt): AnalyticsQuery.filters property in the TX Sheet Control JavaScript API for the browser, with its type AnalyticsFilter[] and a JavaScript example.
- [AnalyticsQuery.limit Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/limit-property/llms-full.txt): AnalyticsQuery.limit property in the TX Sheet Control JavaScript API for the browser, with its type number and a JavaScript example.
- [AnalyticsQuery.measures Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/measures-property/llms-full.txt): AnalyticsQuery.measures property in the TX Sheet Control JavaScript API for the browser, with its type AnalyticsMeasure[] and a JavaScript example.
- [AnalyticsQuery.parameters Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/parameters-property/llms-full.txt): AnalyticsQuery.parameters property in the TX Sheet Control JavaScript API for the browser, with its type Record<string, number> and a JavaScript example.
- [AnalyticsQuery.relationshipIds Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/relationshipids-property/llms-full.txt): AnalyticsQuery.relationshipIds property in the TX Sheet Control JavaScript API for the browser, with its type string[] and a JavaScript example.
- [AnalyticsQuery.sort Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/sort-property/llms-full.txt): AnalyticsQuery.sort property in the TX Sheet Control JavaScript API for the browser, with its syntax and a JavaScript example.
- [AnalyticsQuery.sourceId Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/sourceid-property/llms-full.txt): AnalyticsQuery.sourceId property in the TX Sheet Control JavaScript API for the browser, with its type string and a JavaScript example.
- [AnalyticsQuery.topN Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/topn-property/llms-full.txt): AnalyticsQuery.topN property in the TX Sheet Control JavaScript API for the browser, with its syntax and a JavaScript example.

---

## Nearby

- **Previous:** [AnalyticsFilter.dateGranularity Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsfilter/dategranularity-property/llms-full.txt)
- **Next:** [AnalyticsQuery.sourceId Property](https://docs.textcontrol.com/tx-sheet-control/reference/javascript-api/browser/analyticsquery/sourceid-property/llms-full.txt)
