13

I have a new column in my attribute table with a lot of null values and I want to replace all them to zeros.

How can I do that in field calculator?

I'm using QGIS 1.8

15

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.

2

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.

-1

I just realised that you could edit the –.dbf– file of your shape folder and insert there a new column, row, etc. So! for actualizing the master table of your map. Just find the file i.e.: LATINAMERICA.dbf, open it with LibreOffice (at least I opened it with "Spreadsheets", and it worked perfectly) edit it and then save it as .dbf with the same name and in the same folder. Then reopen the map, and it will have the changes in the master table...It worked for me (Qgis WIEN 2.8) I hope it will work with you all because it was a real pain find that solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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