3

How to show all the strings that contain '841' on this layer?

example1

I tried to use "NAME" LIKE '841' but somehow it did not just show "841_1Q" and "841_1", instead it still showed every point on this layer just highlighting those two containing '841'.

example2

I tried using a wildcard but the "Output preview" shows 0 result.

4
  • 2
    Try using a wildcard character e.g. "NAME" LIKE '841%'.
    – Ben W
    Mar 9 '20 at 4:04
  • 1
    Please, do not forget about "What should I do when someone answers my question?"
    – Taras
    Oct 20 '21 at 5:49
  • 1
    The output preview is often incorrect, always click "Select Features"
    – BERA
    Oct 20 '21 at 6:06
  • 1
    The ouput preview is correct. It shows the result of the evaluated expression ON the FIRST feature of the layer. For bool operation, it could only 0 or 1. It doesn't show you the result of selected features. Switch to QGIS 3.16 minimum, you are going to be able to change the feature in this red circle.
    – etrimaille
    Oct 20 '21 at 6:24
9

It is unclear to me what you want to do exactly. The expression you are using is correct. It highlights the points with the correct expression because you are using "Select By Expression" and the function works exactly as it should be.

If you want to show only those points and hide other points that do not comply with the rule, then you need to use Query Builder from Layer Properties -> Source -> Query Builder and use the following expression:

"Name" LIKE '841%'

It will hide all points (Polygons in this example) that their field name do not start with '841%'.

enter image description here

However, if you want to show only the labels for those points that start with '841', then you need to select the field name Name, and under Rendering go to Show label, and put the following expression:

enter image description here

"Name" LIKE '841%'

Which is same as the above.

Here is the output:

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.