[GIS] Summing up multiple columns values into one single column in QGIS

field-calculatorqgissummarizing

I have one table containing many columns. Using the Field Calculator, I want to create a new column containing (for each line) the sum of all columns values.

I cannot find the correct expression to do this sum.

Best Answer

Using the Field calculator to:

  • sum up columns without NULL values:

    "column1" + "column2" + "column3"
    
  • sum up columns with NULL values:

    "column1" +  (CASE WHEN  "column2" IS NOT NULL THEN "column2" ELSE 0 END) + "column3"
    

Make sure the columns are integer or float values.