Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Returns the sum of all values in a set.
Data
Total:
{d.cars[].qty:aggSum}
Total by sorting "sort" values above 1:
{d.cars[sort>1].qty:aggSum}
Total by multiplying the "qty" by the "sort" attribute:
{d.cars[sort>1].qty:mul(.sort):aggSum:formatC}
Total:
21
Total by sorting "sort" values above 1:
19
Total by multiplying the "qty" by the "sort" attribute:
81
The aggSum
aggregator can be used within loops, for instance:
sum-up people's salaries by departments:
{d.departments[i].people[].salary:aggSum}
{d.departments[i].people[].salary:aggSum(.i)}
(alternative)
global sum of all departments, all people's salary:
{d.departments[i].people[i].salary:aggSum}
{d.departments[i].people[i].salary:aggSum(0)}
(alternative)
Change the partition with dynamic parameters:
sum salaries by people by age, regardless of departments
{d.departments[i].people[i].salary:aggSum(.age)}
sum salaries by people by age and gender, regardless of departments
{d.departments[i].people[i].salary:aggSum(.age, .gender)}
Returns the average of a set.
Average quantity:
{d.cars[].qty:aggAvg}
Average quantity by sorting "sort" values above 1:
{d.cars[sort>1].qty:aggAvg}
Average quantity by multiplying the "qty" by the "sort" attribute:
{d.cars[sort>1].qty:mul(.sort):aggAvg:formatC}
Average quantity:
3.5
Average quantity by sorting "sort" values above 1:
4.75
Average quantity by multiplying the "qty" by the "sort" attribute:
13.50
An aggregate formatter calculates a set of values and returns a single value. For example, the average :aggAvg
takes a list of values and returns the average.
The following aggregators are available:
aggSum returns the sum of all values in a set.
aggAvg returns the average of a set.
aggMin returns the minimum value in a set.
aggMax returns the maximum value in a set.
aggCount returns the number of items in a set.
aggCumSum the cumulative sums, also known as running totals, returns the total sum of data as it grows with series.
Aggregators can be printed as standalone expressions or can be part of loops to compute custom grouping clauses, e.g., sub-totals, cumulative totals.
Returns the minimum value in a set.
Minimum quantity:
{d.cars[].qty:aggMin}
Minimum quantity by sorting "sort" values above 1:
{d.cars[sort>1].qty:aggMin}
Minimum quantity by multiplying the "qty" by the "sort" attribute:
{d.cars[sort>1].qty:mul(.sort):aggMin:formatC}
Minimum quantity:
1
Minimum quantity by sorting "sort" values above 1:
2
Minimum quantity by multiplying the "qty" by the "sort" attribute:
4
Returns the maximum value in a set.
Maximum quantity:
{d.cars[].qty:aggMax}
Maximum quantity by sorting "sort" values above 1:
{d.cars[sort>1].qty:aggMax}
Maximum quantity by multiplying the "qty" by the "sort" attribute:
{d.cars[sort>1].qty:mul(.sort):aggMax:formatC}
Maximum quantity:
10
Maximum quantity by sorting "sort" values above 1:
10
Maximum quantity by multiplying the "qty" by the "sort" attribute:
50
Returns the total sum of data as it grows with series.
The cumulative total of salaries by departments:
{d.departments[i].people[].salary:cumSum}
{d.departments[i+1]}
The cumulative total of salaries by departments and by people:
{d.departments[i].people[i].salary:cumSum}
{d.departments[i+1].people[i+1]}
The cumulative total of salaries by departments: 1000 1700 3200 3400
The cumulative total of salaries by departments and by people: 1000 1500 1700 3200 3400
Returns the number of items in a set.
Count quantity items:
{d.cars[].qty:aggCount}
Count quantity items by sorting "sort" values above 1:
{d.cars[sort>1].qty:aggCount}
Count quantity items by multiplying the "qty" by the "sort" attribute:
{d.cars[sort>1].qty:mul(.sort):aggCount:formatC}
Count quantity items:
10
Count quantity items by sorting "sort" values above 1:
10
Count quantity items by multiplying the "qty" by the "sort" attribute:
50