[GIS] Rule Based Labeling in QGIS

labelingqgis

I have a table of sites that has a field Priority with values 'P1', 'P2', 'P3'. I want to apply rule based labeling such that when a site has Priority = P1
it should be labelled with 'P1', when it has Priority =P2 it should be labelled with 'P2', etc.

I have tried the below formula in the filter under Rule Properties window:
"Priority" = P1 but when I click test I get an error saying Column P1 not found.

Best Answer

Under the "Filter" for rule based labeling write "Priority" = 'P1' (note the double brackets around the column, and the single brackets around the expected result). Single brackets are needed as the expression is searching for a string. The only time you don't need to use single brackets would be when searching for integers.

Related Question