Hi,
Here’s how to filter in QFIELD.
For example, I have a polygons layer named IDENTITY with an attribute field named “name.”
I want to filter this IDENTITY layer based on the value of the attribute field “name.”
To make this possible (adapt with your layer names and fields):
TO FILTER POLYGONS
1- Create a new polygon shapefile layer (for example, name this layer: FILTER)
2- In this layer (FILTER), create a polygon that covers all the features in the IDENTITY layer (this will allow you to populate the filter wherever you are on your map)
3- In this “FILTER” layer, add an editable text field (for example: “my filter”) and create a form containing the “my filter” and “id” fields
4- Switch the “FILTER” layer to edit mode and set the “id” field to 1.
Save, then return to the “FILTER” layer settings and remove “id” from the form
5- In the layer you want to filter (IDENTITY), go to symbology and set it to “by rule set”
6- For unfiltered symbology and a “normal” display of all features, add a rule “+” and check “filter” then write: attribute(get_feature(‘FILTER’,‘id’,1),‘my filter’) IS NULL OR attribute(get_feature(‘FILTER’,‘id’,1),‘my filter’)=‘’
and define the symbology you want to see when there is no filter.
7- For symbology with a filter (displaying filtered features in color), add a second “+” rule and check “filter,” then write: “name”=attribute(get_feature(‘FILTER’,‘id’,1),‘my filter’)
and for the fill, choose, for example, the color red.
For better visibility of your features, you can add symbology using a point geometry generator, define the visibility scale in the symbology, and choose the symbol you want.
And write in the geometry generator:
CASE WHEN “name” = attribute(get_feature(‘FILTER’,‘id’,1),‘my filter’) THEN centroid($geometry) END
8- For symbology with a filter (and to hide features that are not equal to the value entered in the “my filter” layer), add a third rule “+” and check “filter”, then write:
attribute(get_feature(‘FILTER’,‘id’,1),‘my filter’) IS NOT NULL AND “name” <> attribute(get_feature(‘FILTER’,‘id’,1),‘my filter’)
and set the symbology: fill and stroke to transparent.
TO FILTER THE DISPLAY OF LABELS (if you want to display them)
1- Click on the symbol to write a formula and enter the following:
CASE WHEN “name” = attribute(get_feature(‘FILTER’,‘id’,1),‘my filter’) OR attribute(get_feature(‘FILTER’,‘id’,1),‘my filter’) IS NULL OR attribute(get_feature(‘FILTER’,‘id’,1),‘my filter’) = ‘’ THEN “name” END
IN QFIELD
TO APPLY THE FILTER
1- Tap your screen and select “my filter” and the “1” entity
2- Switch to input mode using the A key with the pencil, enter the name you want to filter, then confirm
3- Zoom in or out, and only your filtered entities will be visible
TO REMOVE THE FILTER
1- Tap your screen and select “my filter” and the “your text” entity
2- Switch to input mode using the A key with the pencil, delete the text, then confirm
3- Zoom in or out, and all your entities will be visible
Imported from GitHub discussion by @woupss on 2025-03-23T10:42:11Z