3

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?

1

2 Answers 2

8

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
5

You can use nested if condition 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.