QGIS multiple CASE WHEN doesn’t work in rule-based labelling

labelingqgis

I have the rule-based labelling provided for my labels, inside which I want to make other distinctions. Unfortunately, the multiple CASE WHEN seem to be not valid, as I get an error:

Parser Errors:
syntax error, unexpected STRING
syntax error, unexpected END, expecting $end

My code looks like this so far:

CASE WHEN
"rotate_angle" = 90 THEN
'10,0'
ELSE 
"rotate_angle" = 270 AND "Plan" = E
'8,10'
END

and I believe the situation is similar to this query:

QGIS Multiple CASE WHEN/THEN Statements for Expression Based Labels

where the rule-based styling was proposed. In my case it has been already applied, but I need a step further – a few rules inside of the given rule. Is it possible?

enter image description here

Best Answer

You can't have ELSE with a condition. ELSE is used for catch all others values, so it's a syntax error.

And E seems to be a literal value --> missing quote ('E')

CASE 
  WHEN "rotate_angle" = 90 THEN '10,0'
  WHEN "rotate_angle" = 270 AND "Plan" = 'E' THEN '8,10'
END

or just

CASE 
  WHEN "rotate_angle" = 90 THEN '10,0'
  ELSE '8,10'
END