{ "name": "aggregate", "type": "function", "description": "Returns an aggregate value calculated using features from another layer.", "arguments": [ {"arg":"layer", "description":"a string, representing either a layer name or layer ID"}, {"arg":"aggregate", "description":"a string corresponding to the aggregate to calculate. Valid options are:
"}, {"arg":"calculation", "description":"sub expression or field name to aggregate"}, {"arg":"filter", "optional":true, "description":"optional filter expression to limit the features used for calculating the aggregate"}, {"arg":"concatenator", "optional":true, "description":"optional string to use to join values for 'concatenate' aggregate"} ], "examples": [ { "expression":"aggregate(layer:='rail_stations',aggregate:='sum',expression:=\"passengers\")", "returns":"sum of all values from the passengers field in the rail_stations layer"}, { "expression":"aggregate('rail_stations','sum', \"passengers\"/7)", "returns":"calculates a daily average of \"passengers\" by dividing the \"passengers\" field by 7 before summing the values"}, { "expression":"aggregate(layer:='rail_stations',aggregate:='sum',expression:=\"passengers\")", "returns":"sum of all values from the passengers field in the rail_stations layer"}, { "expression":"aggregate(layer:='rail_stations',calculation:='sum',expression:=\"passengers\",filter:=\"class\">3)", "returns":"sums up all values from the \"passengers\" field from features where the \"class\" attribute is greater than 3 only"}, { "expression":"aggregate(layer:='rail_stations',calculation:='concatenate', expression:=\"name\", concatenator:=',')", "returns":"comma separated list of the name field for all features in the rail_stations layer"} ] }