DynamicWhere.ex
DynamicWhere.exv2.1.0·docs

AggregateBy

An AggregateBy represents one aggregation inside a GroupBy. It produces a single output column named by its Alias.

Properties

PropertyTypeDescription
Fieldstring?Property to aggregate (optional for Count).
Aliasstring?Name of the result column (must not conflict with GroupBy.Fields, no dots).
AggregatorAggregatorAggregation function.
Alias rules
  • Alias must not contain dots — it becomes a top-level property on the resulting dynamic objects in SummaryResult.Data.
  • Alias must not collide with any field name in GroupBy.Fields.
  • Field is required for every aggregator except Count.

C# example

var aggregations = new List<AggregateBy>
{
    new AggregateBy { Aggregator = Aggregator.Count, Alias = "OrderCount" },
    new AggregateBy { Field = "Amount", Aggregator = Aggregator.Sum, Alias = "Revenue" },
    new AggregateBy { Field = "Amount", Aggregator = Aggregator.Avg, Alias = "AverageAmount" }
};

JSON example

[
  { "aggregator": "Count", "alias": "OrderCount" },
  { "field": "Amount", "aggregator": "Sum", "alias": "Revenue" },
  { "field": "Amount", "aggregator": "Avg", "alias": "AverageAmount" }
]

See also