[GIS] QGIS 2.16 Creating virtual field with aggregate expressions

field-calculatorqgisvirtual-field

With QGIS >=2.16, it is possible to use aggregates in expressions, such as sum, average… etc.

But when I use it to create a new virtual field using the field calculator,
the newly created field value is null for all of the layer's entities.

An example here : field calc example

Am I doing it wrong ? Or it is a bug ?

I tried to change the field type with no effect.
Note that it works when you create a non-virtual field.

Best Answer

Fisrt, your field needs to be quoted.

Now look this example, the first one is to add the sum of all the field in each row; the second one, is to sum by row in a specific field.

You have Integer or Real (decimal number) to set your field, depending on what you need to get.

image

Related Question