I'm working with population data, and I have an issue when it comes to knowing the sum of a population inside the attribute table.


In my attribute table, I'd like to add all the numbers in the red box, i.e. all the numbers together from the column "UN_2015_E".

Is there a way to do so?

2 Answers 2


There are several methods that I may refer you to:

1. First one is called "Show statistical summary". Symbolized as a Sigma symbol(Sigma), placed in the main QGIS working window.


In the appearing window, you just need to choose the layer which you are interested in (population data) and choose the field that you want to explore, seems like "UN_2015_E". The total number will be calculated just in the row called 'Sum'.

The same result can be achieved with View > Statistical summary

Or as it was already mentioned by @Erik you can proceed with View > Panels > Statistics Panel

2. There is a Plugin called "Group Stats", see the image below.


3. If you open the Field Calculator, where you can type sum("UN_2015_E") in the Expression dialogue and get the result as a Preview.


In case if you are dealing not with integer values your expression can be altered as round(sum("UN_2015_E"),0)

4. With a hint from @J.R, there is also a possibility with a Virtual layer through Layer > Add Layer > Add/Edit Virtual Layer.

In the Query panel, you just need to type a short statement, see the image below.

FROM "Your_shapefile_name"


In case of not integer values, you can adjust your query as following

FROM "Your_shapefile_name"

5. If you open Plugins > Python Console you can achieve the result by typing the following command in Python prompt

print(sum(filter(None,[f['UN_2015_E'] for f in qgis.utils.iface.activeLayer().getFeatures()])))

The code above calculates the sum of all NOT NULL applying a filter.

Additionally, you can also refer to a layer by its name

print(sum(filter(None,[f['UN_2015_E'] for f in QgsProject.instance().mapLayersByName('your_layer_name')[0].getFeatures()])))

6. Using a QGIS domestic statistical geoalgorithms. Search for "Basic statistics for fields" in the Processing Toolbox. Choose the field "UN_2015_E" and get the result as Sum: ***.


7. And finally it is possible to obtain the summing values via the SAGA's "Field Statistics" tool, which will calculate the sum as one of the parameters.



  • 1
    It is rare to see such a thorough and comprehensive and simple answer to a question. This is wonderful, thank you so much.
    – nittyjee
    Nov 19, 2020 at 9:48
  • @nittyjee, always welcome!
    – Taras
    Nov 19, 2020 at 9:50

Add the statistics panel (view - panels - statistics panel) to your window layout and then let it show you the statistics of your column.

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.