7

I want a new column called "Summed" containing the summed value per "Populatie" name.

How can I accomplish this?

enter image description here

1
  • Welcome to gis.stackexchange! Please note that a good question on this site is expected to show some degree of research on your part, i.e. what you have tried and - if applicable - code so far. For more info, you can check our faq.
    – underdark
    Commented Jun 7, 2017 at 16:18

3 Answers 3

10

You could do it several ways, the way I will suggest is to install the plugin "Group Stats" onto your QGIS version.

enter image description here

Open the Group Stats tool under the Vector tab

enter image description here

Then add your attributes (Populatie) that you want to create the Count.

In your case choose your area to sum the counts associated with each entry

enter image description here

Also, there is a tutorial created by Anita Graser AKA @underdark which is available Group Stats tutorial.

4

You can do this as a field calculation without additional plugins.

Basically, create your new integer/float field to store the sum, and in this case it looks like you want it called "Summed" and then to group the sum by the "Populatie" use the following expression where:

sum("Opp",group_by:="Populatie")

In this case, sum the "Opp" field, but group it by the "Populatie" field.

The syntax from the help says it can take a total of 3 arguments:

Syntax
sum(expression, group_by, filter)

Arguments
expression - sub expression of field to aggregate
group_by - optional expression to use to group aggregate calculations
filter - optional expression to use to filter features used to calculate aggregate

The above provides a sum of a value, but you can use the count() function to count how many times a value appears with something like:

count("Populatie",group_by:="Populatie")

2

(I would prefer to make a comment to ask questions first but I haven't yet attained the privilege. Apologies for skirting the rules.)

What do you envision the data in the new column looking like? Does each row with equal Populatie end up with the same value? Or are you really picturing a new table with each Populatie (listed once) and the respective sum?

If what you ultimately want is the latter, I would suggest simply exporting the table and performing the calculation in other software, e.g. MS Excel. If you go that route (and need help there), here's how I would do it:

  • make a copy of the Populatie column,
  • remove Duplicates (Data tab) in your copied list,
  • and create a formula (in an adjacent cell) using SUMIF:

    =SUMIF([all rows of original Populatie column],[individual cell in unique copies],[all rows of original column you wish to sum])

If you manage your cell references appropriately (absolute references for the first and third arguements, relative for the second), you can copy the formula from one row to the rest.

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