1

This question already has an answer here:

I have a field with building height in levels. I want to create a new field that returns 'low-rise' if buildinglevels < 4. That returns 'mid-rise' if building level is 4-9 and that returns 'high-rise' if building level > 9. I can do this for one condition

If( "buildingle" > 9, 'high-rise' ,pass) 

But when trying the others, they overwrite the previous to NULL. How to solve this?

marked as duplicate by underdark qgis Apr 16 '18 at 17:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

5

I prefer the SQL like syntax for if/else statements

CASE 
  WHEN "buildingle" < 4 THEN 'low-rise'
  WHEN "buildingle" >= 4 AND "buildingle" <= 9 THEN 'mid-rise'
  ELSE 'high-rise'
END
2

You can use nested ifcondition in Field Calculator.

If( "buildingle" > 9, 'high-rise', if( "buildingle" < 4, 'low-rise', 'mid-rise'))

RESULT:

  • .., 2, 3 -> 'low-rise'
  • 4, 5, 6, 7, 8, 9 -> 'mid-rise'
  • 10, 11, ... -> 'high-rise'

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