TX Sheet Control

AnalyticsCalculation Constructor

Constructor
Namespace
TXTextControl.TXSheetControl.Server
Package
TXTextControl.TXSheetControl.Server as TXTextControl.TXSheetControl.Api.dll from the private NuGet feed or the supplied NuGet folder
Also in
TXTextControl.TXSheetControl.Blazor as TXTextControl.TXSheetControl.Api.dll

Syntax

public AnalyticsCalculation()

Return Value

AnalyticsCalculation.

Examples

Create a working document workflow using AnalyticsCalculation. Return the generated document or application data to the caller.

using TXTextControl.TXSheetControl.Server;

async Task<AnalyticsResult> BuildAnalyticsCalculationConstructorAsync(ServerSheetControl control)
{
    var book = control.Workbook;
    var sheet = await book.Sheets.AtAsync(0);
    await sheet.Range("A1:B5").SetValuesAsync(new object?[][]
    {
        ["Region", "Revenue"], ["North", 42000], ["South", 38500], ["East", 31200], ["West", 44900]
    });

    await sheet.Range("C1:C5").SetValuesAsync([["Budget"], [40000], [40000], [30000], [45000]]);
    await book.Analytics.SetSourceAsync(new AnalyticsSource { Id = "sales", Name = "Actual versus budget", SheetId = sheet.Id, Range = "A1:C5", HasHeaderRow = true });

    var variance = new AnalyticsCalculation { Alias = "Variance", Operation = "subtract", Left = "Revenue", Right = "Budget" };
    return await book.Analytics.QueryAsync(new AnalyticsQuery { SourceId = "sales", Dimensions = ["Region"], Measures = [new AnalyticsMeasure { Field = "Revenue", Aggregation = "SUM", Alias = "Revenue" }, new AnalyticsMeasure { Field = "Budget", Aggregation = "SUM", Alias = "Budget" }], Calculations = [variance] });
}

Remarks

Use the member with an instance or settings object from the documented package. Await task-returning operations. Document-bound handles must be resolved again after loading or deleting their owner.

See Also