Is there a command directly in the QGIS field calculator that is equivalent to Excel's SUMIF (without exporting to a CSV file)?

I want to check whether the sum of items in the attribute table which fulfill a specific condition (same ID) is above or below a certain treshold.


marked as duplicate by ahmadhanb, xunilk, whyzar, JGH, Dan C Feb 22 '18 at 15:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Thank you for your answer. I have more than 70,000 rows in my dataset and expoting and importing data may take a lot of time. Is there a way to do this directly in QGIS' field calculator? – Jonas Feb 22 '18 at 8:38
  • 1
    The above duplicate question does what you want. You can use aggregate function in field calculator in QGIS 2.18 or you can use GroupStats plugin if you are using QGIS less than 2.18. – ahmadhanb Feb 22 '18 at 8:43
  • Thank you for your response. The aggregate sum function in QGIS is as follows: sum(expression, group_by, filter). How excatly does that relate to the excel command? In Excel I would use for my dataset '=SUMIF(RANGE - FID_Consum, ROW - FID_Consum, RANGE - Shape_Area)'; i tried the following in QGIS but it does not work: =SUM("FID_Consum", group_by:="FID_Consum", "Shape_Area") – Jonas Feb 22 '18 at 8:53
  • Sorry, I think I got that ... it would be: sum("Shape_Area",group_by:="FID_Consum")? ... but then it says "could not add field to the provider" and the result is higher than the maximum possible value – Jonas Feb 22 '18 at 8:58