I wish to know if there's a tool on QGIS equivalent to the Excel's "SUMIF".

I have a shapefile of a land use and cover that's classified by the attribute with the name of the classes, for example: "vegetation", "urban centers" and "pastures". My goal is to calculate the area of each class, but since it's composed by various polygons, I need to add up all the areas from all polygons that were put in the same class.

Like I mentioned in the beginning of the question, I know that Excel has a function that can do such thing for me, but it turns out that the sum made by excel doesn't match the area's total given by QGIS.

English is not my first language, so if the explanation isn't clear enough, I'll be glad to rephrase it.


Using QGIS 2.18.7, In the Processing Toolbox you need but to search "Statistics by categories" and you fill find a tool that calculates vector table tools.

I have created a teamporary shapefile for an example and created four polygons, two "Pastures" and to "Urban" and gave them both a random value. Then I ran the statistics by categories tool.

My raw data looked like this:

enter image description here

The parameters look like this: in which you input the vector layer, chose the field you want your calculations to be on (for you, this will be the layer area) and chose the field with the categories, so the type of polygon.

enter image description here

And the final result will be a statistics table resembling something like this:

enter image description here

  • 1
    cool, hadn't seen that before! To get the sum of the areas for each category, can use the Export/Add geometry columns first to add the area/perimeter fields – Steven Kay May 8 '17 at 19:16
  • Indeed, I forgot to mention a method for the area value. I actually assumed it was already mentioned but thanks for pointing that out! – Louis May 8 '17 at 19:17
  • 1
    This was very helpful! I'd just like to add that I'm using the standalone version (2.14.7 Essen) and it has the very same feature. You can find it using the exact instructions given by @Louis – Eric Lino May 8 '17 at 20:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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