QGIS/resources/function_help/json/relation_aggregate
Nyall Dawson 2e5257372b [FEATURE] Add order by support to expression aggregate and concatenation functions
Because certain aggregates and concatenation requires results in
a certain order, this change allows specific control of the order
features are added to the aggregate during an expression evaluation.

E.g.

concatenate("Station",concatenator:=',', order_by:="Station")

will give a comma separated list of station names in alphabetical
order, rather than layer feature order.

Sponsored by SMEC/SJ
2019-05-10 06:23:56 +10:00

18 lines
1.8 KiB
Plaintext

{
"name": "relation_aggregate",
"type": "function",
"description": "Returns an aggregate value calculated using all matching child features from a layer relation.",
"arguments": [
{"arg":"relation", "description":"a string, representing a relation ID"},
{"arg":"aggregate", "description":"a string corresponding to the aggregate to calculate. Valid options are:<br /><ul><li>count</li><li>count_distinct</li><li>count_missing</li><li>min</li><li>max</li><li>sum</li><li>mean</li><li>median</li><li>stdev</li><li>stdevsample</li><li>range</li><li>minority</li><li>majority</li><li>q1: first quartile</li><li>q3: third quartile</li><li>iqr: inter quartile range</li><li>min_length: minimum string length</li><li>max_length: maximum string length</li><li>concatenate: join strings with a concatenator</li></ul>"},
{"arg":"expression", "description":"sub expression or field name to aggregate"},
{"arg":"concatenator", "optional":true, "description":"optional string to use to join values for 'concatenate' aggregate"},
{"arg":"filter", "optional":true, "description":"optional filter expression to order the features used for calculating the aggregate. Fields and geometry are from the features on the joined layer."}
],
"examples": [
{ "expression":"relation_aggregate(relation:='my_relation',aggregate:='mean',expression:=\"passengers\")", "returns":"mean value of all matching child features using the 'my_relation' relation"},
{ "expression":"relation_aggregate('my_relation','sum', \"passengers\"/7)", "returns":"sum of the passengers field divided by 7 for all matching child features using the 'my_relation' relation"},
{ "expression":"relation_aggregate('my_relation','concatenate', \"towns\", concatenator:=',')", "returns":"comma separated list of the towns field for all matching child features using the 'my_relation' relation"}
]
}