3

I have a layer with all countries in the world but I need to label only six of them. I tried this expression:

 "NAME"  = 'Russia' AND 'Canada' AND 'China' AND 'USA' AND 'Brazil' AND 'Australia'

But as a result, I get a label only for Russia. Obviously, something is wrong. How can I solve this?

7

If you use an AND your features have to fulfill all your conditions at the same time ... which is probably not what you expect ...

Try something like the following :

Name in ('Russia', 'Canada', 'China', 'USA', 'Brazil', 'Australia')

Use that expression in a rule-based labeling context (Properties/Labels/Rule based labeling and use the previous expression as first rule)

4
  • Thanks! It works even in single labeling!
    – GeoEth
    Jun 30 '21 at 11:15
  • 2
    The long hand would be "NAME" = 'Russia' AND "Name" = 'Canada'...
    – AWGIS
    Jun 30 '21 at 12:03
  • 1
    @AWGIS your comment show the proper syntax for GeoEth wrong expression, the right way would use the OR operator not AND...
    – J.R
    Jun 30 '21 at 13:10
  • Apologies, yes you are correct!
    – AWGIS
    Jul 21 '21 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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