Replacing all null values from attribute table with zeros in QGIS

In QGIS open your attribute table and click the "Select Features Using an Expression" button. To find all the null records for a field in a shape file your query will look like:

"field_name" is null

You can find your field name in the Fields and Values list, double click the field you want to get it into the Expression box.

Make sure you SELECT the new filtered list of records. Then go back to the attribute table and click the Field Calculator button. Check the "Update Existing Field" box - ensuring that the 'only update selected' check box is selected, then select the field you want to update from the dropdown box. Put 0 in the expression box, click OK and you're done.


You can do this directly in the field calculator:

  • Open the field calculator
  • Check the “Update Existing Field” box
  • Select the field you want to work on
  • Enter the following expression in the expression box: if("fieldname" is null, 0, "fieldname"), replacing fieldname with the actual name of you field

It would obviously be safer to create a new field rather than overwriting the old, in case anything goes wrong.