For one country I have

  • population densities (highlighted with a red rectangular) per watershed
  • literacy rate 4.48% (highlighted with a green rectangular)
  • watershed IDs, e.g. 3222, 3271 etc.

I'd like to multiply the population of each watershed by literacy rate. Is there a way to do so?

Perhaps using the field calculator?



2 Answers 2


My suggestion is to deploy a Virtual layer through

Layer > Add layer > Edit/Add Virtual Layer

Please try the following statements in the query field

If you need values for fields that share the same id

SELECT SUM(population_densities*literacy_rate)
FROM your_layer
GROUP BY watershed_number
ORDER BY watershed_number

If you need values for each single field

SELECT population_densities*literacy_rate
FROM your_layer
ORDER BY watershed_number



You need to convert your literacy rate text to real in order to do the calculation. The rate 4,48 is of text type, thus, you need to convert it to real type to become 4.48 as number not as text. To do that, create a new field of type real (decimal) and name it "Rate_Num" for example, and under "Rate_Num" write the following expression to convert the rate text into rate number:

to_real(replace("Rate_text", ',','.'))

Then add a new field of type real (decimal) to calculate the population density and multiply the "Population" field with the "Rate_Num" field using the following formula, in this example the new field name is "Result", :


enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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