I can't seem to be able to troubleshoot my expression here. I'm trying to calculate a new field. Column "FOO_U_CODE" contains numerous 4 digit codes, the new column I want to create is a simplified version based on the first character of the code in "FOO_U_CODE".
I saw somewhere that you can use % to specify anything after one or multiple characters. Is it right?
What is wrong here?
CASE
WHEN "F00_U_CODE" IS'1%' THEN "Utilisatio" = 'Residentiel'
WHEN "F00_U_CODE" IS'2%' THEN "Utilisatio" = 'Transports communications et services publics'
WHEN "F00_U_CODE" IS'3%' THEN "Utilisatio" = 'Industrielle'
WHEN "F00_U_CODE" IS'4%' THEN "Utilisatio" = 'Transports, communications et services publics'
WHEN "F00_U_CODE" IS'5%' THEN "Utilisatio" = 'Commerciale'
WHEN "F00_U_CODE" IS'6%' THEN "Utilisatio" = 'Services'
WHEN "F00_U_CODE" IS'7%' THEN "Utilisatio" = 'Culturelle, recreative et loisirs'
WHEN "F00_U_CODE" IS'8%' THEN "Utilisatio" = 'Production et extraction des richesses naturelles'
WHEN "F00_U_CODE" IS'9%' THEN "Utilisatio" = 'Immeubles non exploites et etendues deau'
END
Best Answer
You should probably use
LIKE
instead ofIS
.If "Utilisatio" is your new field, you don't have to specify it explicitely in the field calculator (just write
WHEN "F00_U_CODE" LIKE '1%' THEN 'Residentiel'
for instance).