# AnalyticsQuery Class

> AnalyticsQuery class in the .NET API: Bounded, deterministic query. Joined columns use targetSourceId.fieldId. Sorting ties preserve source order.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Class
- **Namespace:** `TXTextControl.TXSheetControl.Server`
- **Package:** `TXTextControl.TXSheetControl.Server` (assembly `TXTextControl.TXSheetControl.Api.dll`, from the private NuGet feed or the supplied NuGet folder)
- **Package:** `TXTextControl.TXSheetControl.Blazor` (assembly `TXTextControl.TXSheetControl.Api.dll`, from the private NuGet feed or the supplied NuGet folder)
- **Path:** TX Sheet Control > API Reference > .NET API > TXTextControl.TXSheetControl.Server > AnalyticsQuery Class
- **2319 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/llms-full.txt

---

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

### Members

| Property | Description |
|---|---|
| [SourceId](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/sourceid-property/llms-full.txt) | Typed source id setting; validated by the owning dashboard operation. |
| [Dimensions](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/dimensions-property/llms-full.txt) | Typed dimensions setting; validated by the owning dashboard operation. |
| [Measures](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/measures-property/llms-full.txt) | Typed measures setting; validated by the owning dashboard operation. |
| [Calculations](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/calculations-property/llms-full.txt) | Explicit arithmetic on aggregated aliases; missing operands remain null. |
| [DateGrouping](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/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/dotnet-api/txtextcontrol-txsheetcontrol-server/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/dotnet-api/txtextcontrol-txsheetcontrol-server/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/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/filters-property/llms-full.txt) | Typed filters setting; validated by the owning dashboard operation. |
| [RelationshipIds](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/relationshipids-property/llms-full.txt) | Typed relationship ids setting; validated by the owning dashboard operation. |
| [Sort](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/sort-property/llms-full.txt) | Typed sort setting; validated by the owning dashboard operation. |
| [Limit](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/limit-property/llms-full.txt) | Typed limit setting; validated by the owning dashboard operation. |

### Examples

Create and configure a sales dashboard, then write the resulting SVG report.

```csharp
using System.Text.Json;
using TXTextControl.TXSheetControl.Server;

async Task ConfigureSalesDashboard(ServerSheetControl control)
{
    var book = control.Workbook;
    var sheet = await book.Sheets.AtAsync(0);
    await sheet.Range("A1:G5").SetValuesAsync(new object?[][] {
        ["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]
    });
    await book.Analytics.SetSourceAsync(new() { Id = "sales", Name = "Sales", SheetId = sheet.Id, Range = "A1:G5", HasHeaderRow = true });
    var dashboard = await book.Dashboards.AddAsync("Sales Performance");
    await dashboard.UpdateAsync(new { sections = new DashboardSection[] { new() { Id = "summary", Title = "Executive Summary" } } });
    await dashboard.AddWidgetAsync(new() {
        Id = "revenue", Type = "column", Title = "Regional Revenue",
        Placement = new() { X = 0, Y = 0, Width = 8, Height = 6 },
        Query = new() { SourceId = "sales", Dimensions = ["Region"], Measures = [
            new() { Field = "Revenue", Aggregation = "SUM", Alias = "Revenue" },
            new() { Field = "Profit", Aggregation = "SUM", Alias = "Profit" }
        ] }
    });
    var settings = JsonSerializer.Deserialize<AnalyticsQuery>(
        """
        {
            "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
        }
        """, new JsonSerializerOptions(JsonSerializerDefaults.Web))!;
    await dashboard.UpdateWidgetAsync("revenue", new { query = settings });
    await File.WriteAllTextAsync("sales-dashboard.svg", await dashboard.RenderSvgAsync());
}
```

---

## In This Section

- [AnalyticsQuery.Calculations Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/calculations-property/llms-full.txt): AnalyticsQuery.Calculations property in the TX Sheet Control .NET API: Explicit arithmetic on aggregated aliases; missing operands remain null.
- [AnalyticsQuery Constructor](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/constructor/llms-full.txt): AnalyticsQuery constructor in the TX Sheet Control .NET API, with its syntax, a C# example and remarks on awaiting tasks and handles.
- [AnalyticsQuery.DateGrouping Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/dategrouping-property/llms-full.txt): AnalyticsQuery.DateGrouping property in the TX Sheet Control .NET API, with its type AnalyticsDateGrouping[]? and a C# example.
- [AnalyticsQuery.Dimensions Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/dimensions-property/llms-full.txt): AnalyticsQuery.Dimensions property in the TX Sheet Control .NET API, with its syntax, its type string[]? and a C# example.
- [AnalyticsQuery.Filters Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/filters-property/llms-full.txt): AnalyticsQuery.Filters property in the TX Sheet Control .NET API, with its syntax, its type AnalyticsFilter[]? and a C# example.
- [AnalyticsQuery.Limit Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/limit-property/llms-full.txt): AnalyticsQuery.Limit property in the TX Sheet Control .NET API: Typed limit setting; validated by the owning dashboard operation.
- [AnalyticsQuery.Measures Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/measures-property/llms-full.txt): AnalyticsQuery.Measures property in the TX Sheet Control .NET API, with its syntax, its type AnalyticsMeasure[] and a C# example.
- [AnalyticsQuery.Parameters Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/parameters-property/llms-full.txt): AnalyticsQuery.Parameters property in the TX Sheet Control .NET API, with its type Dictionary<string, double>? and a C# example.
- [AnalyticsQuery.RelationshipIds Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/relationshipids-property/llms-full.txt): AnalyticsQuery.RelationshipIds property in the TX Sheet Control .NET API, with its syntax, its type string[]? and a C# example.
- [AnalyticsQuery.Sort Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/sort-property/llms-full.txt): AnalyticsQuery.Sort property in the TX Sheet Control .NET API, with its syntax, its type AnalyticsSort? and a C# example.
- [AnalyticsQuery.SourceId Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/sourceid-property/llms-full.txt): AnalyticsQuery.SourceId property in the .NET API: Typed source ID of a bounded, deterministic analytics query, validated by the owning dashboard operation.
- [AnalyticsQuery.TopN Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/topn-property/llms-full.txt): AnalyticsQuery.TopN property in the TX Sheet Control .NET API: Retains the highest/lowest groups and optionally aggregates all remaining groups into Other.

---

## Nearby

- **Previous:** [AnalyticsProfile.Source Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsprofile/source-property/llms-full.txt)
- **Next:** [AnalyticsQuery Constructor](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticsquery/constructor/llms-full.txt)
