My QGIS Field Calculator expression:

case when "field_value" = '' or  "field_value" <> NULL then (if( "field_value" = '', 'N', 'Y')) end

returns null value even if "field_value" has something in it.

Note: "field_value" is in string.


(Edited answer)

I think you can safely replace your main condition with "field_value" is not NULL (the comparison with null is somewhat counter-intuitive):

  when "field_value" is not null then if( "field_value" = '', 'N', 'Y')
  • I think else is an optional condition and not required. – Keshav Sharma Apr 19 '19 at 13:39
  • this either isn't working. – Keshav Sharma Apr 19 '19 at 13:43
  • @KeshavSharma You're right, I misunderstood your expression. I've edited my answer (and tested it this time...), I think it should work. – ArMoraer Apr 19 '19 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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