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?

Geographos
  • 4,087
  • 2
  • 27
  • 88

1 Answers1

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

J.R
  • 16,090
  • 1
  • 19
  • 52