Returns the sum of all values in a set.


  "cars": [

Total: {[].qty:aggSum}

Total by sorting "sort" values above 1: {[sort>1].qty:aggSum}

Total by multiplying the "qty" by the "sort" attribute: {[sort>1].qty:mul(.sort):aggSum:formatC}

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)}

Last updated