I'm trying to replace selected string values in an attribute table, eg. "Text1" for "Text2" (QGIS 1.8.0), patriculary for those rows with NULL values. I have been trying to use the replace expression (and any other that I have found) with no luck.
Are there any wildcard characters that I may be able to use in future?
Answer
You could try a case when expression:
case when "Column_1" is NULL then replace("Column_2",'Text2','Text1') else "Column_2" end
Using the 'or' expression, you can add multiple columns with NULL-values to the code.
case when "Column_1" is NULL or "Column_3" is NULL then replace("Column_2",'Text2','Text1') else "Column_2" end
edit:
If you want to replace NULL, forget the replace-expression (it only works for strings and NULL is no string). Try this exact code:
case when "Feature" is NULL then '12_1' else "Feature" end
No comments:
Post a Comment