I have a string field I wish to convert to int. A small subset of the records contain NULL.
I tried the following in the field calculator:

case
when ("bb_usage" IS NULL) then 0
else to_int("bb_usage"")
end
When I look at the preview, the result is correct whether or not the field contains int or NULL. But when I try to run it, I get an error:
 
       

I also tried

case
when ("bb_usage" IS NULL) then 0
when  ("bb_usage" IS NULL) then to_int("bb_usage")
end
and get the same error.

I tried
if ("bb_usage" IS NULL, 0, to_int("bb_usage"))
same error.

I know there are workarounds, but why don't any of these work? Why does to_int get evaluated on the NULLs?
_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to