1

I want to write down the function for my polygons in QGIS, which will customize more than 1 criteria.

I am based on my previous situation, which has been solved here:

QGIS 3x - categorized style customization based on a part of the string

enter image description here

apart from the polygons with defined ID I also have quite a few without the ID, called as "Unknown".

Due to this, I modified my existing function a bit:

    "ID" LIKE 'SE-2%'  AND "ID" LIKE 'Unknown'

but something must be wrong, as I am getting one value only...

enter image description here

I think this is something related to this thread:

gis.stackexchange.com/questions/119995/qgis-categorized-styling-by-multiple-columns

Is there a way to execute both polygons with different front string (SN-1 or SN-2) and the "Unknown" ones at once?

7
  • I don't get why you say you had more than one criteria?
    – Erik
    Jul 20 '20 at 14:36
  • Simply, more than 1 string variables to distinguish.
    – MKR
    Jul 20 '20 at 14:38
  • Yeah, but that's just the usual categorising?
    – Erik
    Jul 20 '20 at 14:40
  • I meant the way which has been answered below
    – MKR
    Jul 20 '20 at 14:40
  • So you wanted to assign specific values to several categories? Maybe you could edit your question so it becomes more clear?
    – Erik
    Jul 20 '20 at 14:44
3

You should use the OR operator. By using the AND you are trying to get ID's that begin with 'SE-2' AND are equal to 'Unknown' at the same time when you want those that are one OR the other.

Even if your way of categorizing work I suggest to use rule based styling as in my opinion it's easier to set up more rule or a few complex rule.

In the picture below I set some exemple of rule based styling for your case (you just have to click on the '+' button and fill the filter field with your expression, you may add a text in the label field (this text appear in the layers panel and in legend))

In my exemple I set more rule than you need for illustration purpose (2 different rule for SE-2 and Unknown as separate category (red and blue) and one for SE-2 and Unknown in the same category (orange), don't use all three at the same time or you get duplicate (you may check for duplicate by clicking on the sigma symbol right of the '+' button and look at the duplicate count on the far right of the window), I also add an ELSE rule (purple) to catch all other case.

enter image description here

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.