# AnalyticsCalculation Class

> AnalyticsCalculation class in the .NET API: A bounded arithmetic or ordered-window calculation on grouped query results; division by zero yields null.

- **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 > AnalyticsCalculation Class
- **1794 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticscalculation/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticscalculation/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/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.

### Members

| Property | Description |
|---|---|
| [Alias](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticscalculation/alias-property/llms-full.txt) | Unique result column name. |
| [Operation](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticscalculation/operation-property/llms-full.txt) | Deterministic calculation operation; see the supported operations in the dashboard analytics guide. Supported values: add, subtract, multiply, divide, percent-of-total, running-total, moving-average, rank, difference, percent-change. |
| [Left](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticscalculation/left-property/llms-full.txt) | Previously declared numeric alias or `@parameterId`. |
| [Right](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticscalculation/right-property/llms-full.txt) | Second numeric alias or `@parameterId` for arithmetic operations. |
| [Window](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticscalculation/window-property/llms-full.txt) | Moving-average trailing window length, 1..1000; defaults to 3. |

### 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<AnalyticsCalculation>(
        """
        {
            "alias": "Margin",
            "operation": "divide",
            "left": "Profit",
            "right": "Revenue",
            "window": 3
        }
        """, new JsonSerializerOptions(JsonSerializerDefaults.Web))!;
    await dashboard.UpdateWidgetAsync("revenue", new { query = new AnalyticsQuery { SourceId = "sales", Dimensions = ["Region"], Measures = [new() { Field = "Revenue", Alias = "Revenue", Aggregation = "SUM" }, new() { Field = "Profit", Alias = "Profit", Aggregation = "SUM" }], Calculations = [settings] }, chart = new DashboardChartSettings { YField = "Margin" } });
    await File.WriteAllTextAsync("sales-dashboard.svg", await dashboard.RenderSvgAsync());
}
```

---

## In This Section

- [AnalyticsCalculation.Alias Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticscalculation/alias-property/llms-full.txt): AnalyticsCalculation.Alias property in the TX Sheet Control .NET API, with its syntax, its type string and a C# example.
- [AnalyticsCalculation Constructor](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticscalculation/constructor/llms-full.txt): AnalyticsCalculation constructor in the TX Sheet Control .NET API, with its syntax, a C# example and remarks on awaiting tasks and handles.
- [AnalyticsCalculation.Left Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticscalculation/left-property/llms-full.txt): AnalyticsCalculation.Left property in the .NET API: Previously declared numeric alias or `@parameterId`. Shown with its type string and a C# example.
- [AnalyticsCalculation.Operation Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticscalculation/operation-property/llms-full.txt): AnalyticsCalculation.Operation property in the TX Sheet Control .NET API, with its syntax, its type string and a C# example.
- [AnalyticsCalculation.Right Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticscalculation/right-property/llms-full.txt): AnalyticsCalculation.Right property in the TX Sheet Control .NET API: Second numeric alias or `@parameterId` for arithmetic operations.
- [AnalyticsCalculation.Window Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticscalculation/window-property/llms-full.txt): AnalyticsCalculation.Window property in the TX Sheet Control .NET API: Moving-average trailing window length, 1..1000; defaults to 3.

---

## Nearby

- **Previous:** [Analytics.SuggestRelationshipsAsync Method](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analytics/suggestrelationshipsasync-method/llms-full.txt)
- **Next:** [AnalyticsCalculation Constructor](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/analyticscalculation/constructor/llms-full.txt)
