[GIS] Calculating percentage using QGIS Field Calculator

field-calculatorqgis

I have a shapefile containing counties and their respective population for a given area. I woould like to use the Field Calculator to create a new field that contained the % of the total population in each county. I was looking for a way of doing it in one step inside the Field Calculator, i.e., how to build an expression that states something like "divide the population of each county by the sum of the population of all counties in this same column and multiply it by 100". I'm actually stuck in the "sum of all values" part…

Not sure if I'm demanding too much of a simple solution or if I'm just being blindsided and not seeing some obvious answer. Anyone?

Best Answer

If you dont have to iterate through to solve multiple fields then you are right on track, but just use statistics to get your total sum (in the attribute table right click on the pop field and choose statistics). Then set up your expression with the exact logic you stated above

[New_Field] =

([POP_COUNTY_FIELD] / Total Population) * 100

Total Population will be the value you found from statistics