I am using QGIS 2.18.

I'm trying to sum fields based on two criteria with filed calculator.

I have the "ID" field and the "ZONE" field (ID is secondary key, repited for other table). ZONE field has a value 01;02;03.I want to summarize the field "VALUE" based on the ID field, and ZONE field.

aggregate( 'ID', 'sum' , "VALUE" , "ZONE" = 01)

aggregate( 'ID', 'sum' , "VALUE" , "ZONE" = 02) ect.

enter image description here

  • 1
    What is your question? A single question mark somewhere in your question body would make that obvious.
    – PolyGeo
    Oct 26, 2018 at 10:01

1 Answer 1


Try sum() instead.

sum("Value", group_by:= concat("ID", "ZONE"))

enter image description here

  • 1
    Thanks @nagib aggregate() is an excellent function when you work across multiple layers. It only lacks group_by option, so I recommended sum().
    – Kazuhito
    Oct 26, 2018 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.