QGIS Multiple CASE WHEN/THEN Statements for Expression Based Labels

المشرف العام

Administrator
طاقم الإدارة
I am trying to label a single point with multiple labels, based on the attributes for that point. For example, if one of the attributes is equal to 1, I want to label it with a specific text string; and if another attribute is equal to 0, I want to label it with a different text string, etc. In addition, I want to use other attribute information to control the placement of the labels around the point, as well as their color.

Can multiple CASE WHEN/THEN expressions be stacked, to achieve the desired result? I have tried to include multiple WHEN/THEN statements inside my CASE expression, looking like this:

CASEWHEN attribute1 = 1 THEN 'Apple'WHEN attribute2 = 0 THEN 'Grape'WHEN attribute3 >= 0 THEN 'Pear'ENDThis returns the desired label for attribute1, but ignores the labels for the other two attributes. I believe this is because a CASE statement can only refer to a single variable/attribute at a time? If that is true, is there another conditional expression type I can use to achieve what I want? I'm trying to avoid having to add the point layer multiple times to my project, in order to label based on different attributes.



أكثر...
 
أعلى