I have an attribute table where one of the columns (laeskaerm) has been edited/created by checkboxes on 2 different machines.

Result: it contains both 1, 0, true, false and NULL

I'd like to replace 1 with true, and 0 with false. I've tried:




But I can't seem to make it work (QGIS 2.2.0).

Do anyone have any idea whats wrong?

  • 2
    What data type are your attributes?
    – karpfen
    Jan 15, 2016 at 11:03
  • As far as I can see, the field-type is set to Qstring, but I do not know wether it have been changed earlier
    – Lars Peter
    Jan 15, 2016 at 11:08
  • The second one, you meant replace("laeskaerm",'0','false'), right? Jan 16, 2016 at 11:22

3 Answers 3


You could use the following expression to update your "laeskaerm" field:

CASE WHEN "laeskaerm" = 1 THEN 'True' 
WHEN "laeskaerm" = 2 THEN 'False'
ELSE "laeskaerm"
  • I just tried this, but with no result. No changes were made in the column
    – Lars Peter
    Jan 15, 2016 at 11:13
  • @LarsPeter - Make sure you're editing mode before using the field calculator. If you were then perhaps your shapefile are read-only or protected?
    – Joseph
    Jan 15, 2016 at 11:23
  • I've had the same thought (made that error before) but that didn't seem to be the case this time. BUT I tried 2 different editing plugins. The first crashed, the second one seems to be able to slove my problem. Thank you for your time
    – Lars Peter
    Jan 15, 2016 at 11:40
  • @LarsPeter - Awesome, glad you got it solved! You should post your solution as an answer so that others could benefit if they experience the same problem. Also, have you tried re-saving it as a new shapefile and then edit it using the field calculator?
    – Joseph
    Jan 15, 2016 at 11:44
  • 1
    funnily enough it didn't occur to me to resave and edit, probertly should have thought af that as one of the first things
    – Lars Peter
    Jan 15, 2016 at 11:50

I found a solution

Instead of editing the fields myself I found a plugin that coould do the job (quickmultiattributeedit)

Thank you for your help and time


Try this

if("laeskaerm"='1' OR "laeskaerm"='true','true','false')

in 2.2

Case when "laeskaerm"='1' OR "laeskaerm"='true' then 'true'
Else 'false'
  • I'm not allowed to do so. I recieve a syntax error (syntax error, unexpected '(', expecting $end)
    – Lars Peter
    Jan 15, 2016 at 11:21

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.