2

This question already has an answer here:

I have an attribute table with a real data type column named "Volume". Some of these cells have no value, and I want to replace the NULL with a dummy value like -999. In the Field Calculaor I select "Update Existing Field", select the "Volume" field and I attempt the following:

1) I code CASE WHEN NULL THEN -999 END - Result: the entire column becomes NULL.

2) Then I try CASE WHEN "Volume" IS NULL THEN -999 END - Result, the NULL valued cells now show -999 BUT all the other formerly filled cells are now NULL. After many hours of trying other expression variations I can't figure this out. My guess is I am missing a basic concept.

Oh, and how can I "undo" a bad field calculator update besides quitting QGIS and discarding the updates.

marked as duplicate by Fezter Jan 19 '17 at 23:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3

You need to include an ELSE statement, like this:

CASE WHEN "VOLUME" IS NULL THEN -999
ELSE "VOLUME" END

Not sure about undoing a bad expression other than toggling off editing and not saving your changes.

0

Use the select feature by expression to select all the rows that have a NULL volume. enter image description here

Then open the field calculator. Select "update existing", select your "Volume" field, and select the "Only update Existing" option. Type in the value you wish to update to and select okay. Example is pictured below. enter image description here

  • "Select by Expression" worked. – SteveG Jan 19 '17 at 22:33

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