Tip Filter in QFIELD

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

VERSION FRANÇAISE
Salut,
Voilà comment il faut faire pour pouvoir filtrer dans QFIELD.

Pour l’exemple, j’ai une couche de polygones nommée IDENTITE dans laquelle il y a un champ d’attributs “nom”.

Je souhaite filtrer cette couche IDENTITE selon la valeur du champ d’attributs “nom”.
Pour rendre ceci possible (à adapter avec vos noms de couche et champs):

POUR FILTRER LES POLYGONES

1- créez une nouvelle couche shapefile de polygone ( par exemple nommez cette couche: FILTRE)

2- dans cette couche (FILTRE), créez un polygone qui recouvre toutes les entités de la couche IDENTITE (ceci vous permettra de renseigner le filtre où que vous soyez sur votre carte)

3- dans cette couche “FILTRE”, ajoutez un champ en texte éditable (par exemple : “mon filtre”)
et créez un formulaire contenant le champ “mon filtre” et “id”

4- passez en mode édition la couche “FILTRE” et renseignez le champ “id” à 1, enregistrez puis revenez dans les paramètres de la couche “FILTRE” et retirez “id” du formulaire

5- dans la couche que vous souhaitez filtrer (IDENTITE), allez dans symbologie et définissez “par ensemble de règles”

6- Pour la symbologie sans filtre et un affichage “normal” de toutes les entités ajoutez une règle “+” et cochez “filtre” puis écrivez :
attribute(get_feature(‘FILTRE’,‘id’,1),‘mon filtre’) IS NULL OR attribute(get_feature(‘FILTRE’,‘id’,1),‘mon filtre’)=‘’
et définissez la symbologie que vous souhaitez voir quand il n’y a pas de filtre.

7- Pour la symbologie avec filtre (affichage en couleur des entités filtrées) ajoutez une deuxième règle “+” et cochez “filtre” puis écrivez :
“nom”=attribute(get_feature(‘FILTRE’,‘id’,1),‘mon filtre’)

et pour le remplissage choisissez, par exemple la couleur rouge.
Pour une meilleur visibilité de vos entités vous pouvez ajouter une symbologie par générateur de géométrie en point et définir l’échelle de visibilité dans la symbologie et choisir le symbole que vous souhaitez.
A écrire dans le générateur de géométrie :
CASE
WHEN “nom”=attribute(get_feature(‘FILTRE’,‘id’,1),‘mon filtre’)
THEN centroid($geometry)
END

8- Pour la symbologie avec filtre (et masquer les entités qui ne sont pas égales à la valeur renseignée dans la couche “mon filtre”) ajoutez une troisième règle “+” et cochez “filtre” puis écrivez :

attribute(get_feature(‘FILTRE’,‘id’,1),‘mon filtre’) IS NOT NULL AND “nom”<>attribute(get_feature(‘FILTRE’,‘id’,1),‘mon filtre’)

et mettre la symbologie : remplissage et trait en transparent.

POUR FILTRER L’AFFICHAGE DES ÉTIQUETTES (si vous voulez en afficher)

1- Cliquez sur le symbole pour écrire une formule et renseignez comme suit :

CASE WHEN
“nom”=attribute(get_feature(‘FILTRE’,‘id’,1),‘mon filtre’)
OR
attribute(get_feature(‘FILTRE’,‘id’,1),‘mon filtre’) IS NULL OR attribute(get_feature(‘FILTRE’,‘id’,1),‘mon filtre’)=‘’
THEN “nom”
END

DANS QFIELD

POUR APPLIQUER LE FILTRE

1- appuyer sur votre écran et sélectionnez “mon filtre” l’entité “1”

2- passer en mode saisie via le A avec le crayon, saisissez le nom que vous voulez filtrer puis validez

3- zoomez ou dézoomez et uniquement vos entités filtrées seront visibles

POUR RETIRER LE FILTRE

1- appuyer sur votre écran et sélectionnez “mon filtre” l’entité “votre texte”

2- passer en mode saisie via le A avec le crayon, supprimez le texte puis validez

3- zoomez ou dézoomez et toutes vos entités seront visibles


Imported from GitHub comment by @woupss on 2025-03-23T10:45:57Z