aggAvg

Returns the average of a set.

Data

{
  "cars": [
    {"brand":"Lu","qty":1,"sort":1},
    {"brand":"Fa","qty":4,"sort":4},
    {"brand":"Vi","qty":3,"sort":3},
    {"brand":"Fa","qty":2,"sort":2},
    {"brand":"To","qty":1,"sort":1},
    {"brand":"Vi","qty":10,"sort":5}
  ]
}

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}

Last updated