2

When I run this statement in qgis fieldcalc it returns correct reults only from the first line ('Skog') and the rest gets NULL-values.

Any ideas what might be wrong here? Is it not pocssible to run CASE-statement inlcuding several lines? It seems to work when I run it with the three middle rows excluded.

CASE  
when "KATEGORI"  LIKE '%skog' then 'Skog'  
when "KATEGORI"  LIKE '%vatten%' then 'Vattenomrade'  
when "KATEGORI"  LIKE '%Annan%' then 'Oppen mark'  
when "KATEGORI"  LIKE '%ker%' then 'Oppen mark'  
Else 'Bebyggd och Hardgjord mark'  
END

 

2
  • Your syntax looks fine. Could you add your attribute table (or part of it) to your question? Also, this answer might help.
    – ArMoraer
    Apr 17, 2018 at 8:05
  • Thanks for helpful link! However, It all worked out just by changning som letters to upper case.
    – Spiran
    Apr 17, 2018 at 8:54

1 Answer 1

1

Try:

CASE KATEGORI 
   WHEN '%skog' THEN 'Skog'  
   WHEN '%vatten%' THEN 'Vattenomrade'  
   WHEN '%Annan%' THEN 'Oppen mark'  
   WHEN '%ker%' THEN 'Oppen mark'  
   ELSE 'Bebyggd och Hardgjord mark' 
END
1
  • Thanks! My first syntax was correct after all, except for some mistakes using lower case....
    – Spiran
    Apr 17, 2018 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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