I have a line shapefile that has a bunch of data and it is broken down into different features which is assigned a different number. It is then styled on the rule based approach so each feature gets a different symbology.

What I am wanting to do is to take one feature (skid trail - "feature" = '11') and have 2 or 3 different color of lines based on what the corresponding column "label" says. In the picture you can see my attempt in the expression string builder but I'm not very good at it. I also want to make sure that if there is no value or another word in the "label" field that it will still display a line.

I know that I could add another rule with a different feature number (ex. feature = 44) but because this data is shared between others we keep the data info the same.

As I was typing this I was wondering if I could even just do this under the rule based symbology style and not even use the expression builder.


2 Answers 2


Yes, either way (making expression with conditions or rule-based symbology) will work fine.

As to the expression in the attached image, you could modify it to:

 WHEN "feature" = 11 AND "label" = 'Existing' THEN color_rgb(255,0,0) 
 WHEN "feature" = 11 AND "label" = 'Proposed' THEN color_rgb(0,255,0)
 WHEN "feature" = 11 AND "label" = NULL       THEN color_rgb(0,0,255)
 ELSE color_rgb(0,0,0)

It is also advisable to add ELSE, which will handle cases when none of your conditions match the data.


And to do it with rule-based labeling, remember that you can nest rules inside of other rules. So you'd have a rule where FEATURE = 11, and inside of that you'd have 2 or 3 sub-rules for the LABEL values (including an "else" option with no value defined for LABEL).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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