|
| 1 | +--- |
| 2 | +description: Add custom filters to sort and display only those features that you need during your field survey. |
| 3 | +--- |
| 4 | + |
| 5 | +# Feature Filtering in Mergin Maps Mobile App |
| 6 | +[[toc]] |
| 7 | + |
| 8 | +Custom filters can be added to the <MobileAppNameShort /> to easily filter features displayed on the map as well as in the [survey layers](../layers/#browsing-features). |
| 9 | + |
| 10 | +::: tip Feature filtering blog |
| 11 | +You can read about this feature also on our blog <MainDomainNameLink id="blog/from-wishlist-to-app-feature-filtering-is-live" desc="From wishlist to app: Feature filtering is live"/>. |
| 12 | +::: |
| 13 | + |
| 14 | +## Enable and define filtering in QGIS |
| 15 | +Filters can be enabled and defined in QGIS in **Project Properties**. |
| 16 | + |
| 17 | +::: tip Plugin upgrade |
| 18 | +If you do not see the **Filtering** option in the **Project properties**, check for [plugin upgrades](../../setup/install-mergin-maps-plugin-for-qgis/#plugin-upgrade). |
| 19 | +::: |
| 20 | + |
| 21 | +Check the :heavy_check_mark: **Enable filtering** option in the <MainPlatformName /> tab, click on the **Add filter** button and select a filter type from the list. The list of available [filter types](#filter-types) and their properties can be found below. |
| 22 | + |
| 23 | +Then, define the filter: |
| 24 | + - **Type** - the filter type (in general, it should match the widget type of the filtered field) |
| 25 | + - **Layer** - choose from the project's layers |
| 26 | + - **Field** - choose from the fields of the layer. Only fields with data types compatible with the selected filter type are offered. |
| 27 | + - **Title** - the name of the filter, which will be displayed in the <MobileAppNameShort /> |
| 28 | + |
| 29 | +  |
| 30 | + |
| 31 | +You can add as many filters as you need by using the **Add filter** button. |
| 32 | + |
| 33 | +The order of filters can be changed by selecting a filter and using the **Up** and **Down** buttons. To remove a filter, select it and click the **Remove** button. |
| 34 | + |
| 35 | + |
| 36 | +Don't forget to save your project and synchronise changes so that you can use the filters in the <MobileAppNameShort />. |
| 37 | + |
| 38 | + |
| 39 | +### Filter types |
| 40 | + |
| 41 | +**Text** filter uses simple text input. Results are filtered based on the SQL expression `"field" ILIKE '%input%'`. Available for text and number field types. |
| 42 | + |
| 43 | +**Number** filter provides *from* and *to* number inputs. Results are filtered based on SQL expression `"field" >= 'input_from' AND "field" <= 'input_to'`. Available for text and number field types. |
| 44 | + |
| 45 | +**Date** filter provides *from* and *to* date (calendar) inputs. Results are filtered based on SQL expression `"field" >= 'input_from' AND "field" <= 'input_to'`. Available for date field types configured with the [Date and time widget](../../layer/date-time/). |
| 46 | + |
| 47 | +**Boolean** filter provides a toggle between *all*, *true* and *false* values. Results are filtered based on SQL expression `"field" == 'input'`. Available for Boolean, text and integer field types configured with the [Checkbox widget](../../layer/checkbox/). |
| 48 | + |
| 49 | +**Single select** filter provides a drop-down menu of field values. One value can be selected at once. The results are filtered based on SQL expression `"field" == 'input'`. Available for text and number field types configured with the [Value map or Value relation widget](../../layer/value-select/). |
| 50 | + |
| 51 | +**Multi select** filter provides a drop-down menu of field values. Multiple values can be selected at once. The results are filtered based on SQL expression `"field" IN ('input')`. Available for text and number field types configured with the [Value map or Value relation widget](../../layer/value-select/#value-relation). |
| 52 | + |
| 53 | +In the <MobileAppNameShort />, the filter types looks as follows: |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | +## Filtering features in the mobile app |
| 58 | +Filters defined in [<MainPlatformName /> project in QGIS](#enable-and-define-filtering-in-qgis) can be used in the <MobileAppNameShort />. You can filter features across multiple layers by entering or selecting values in corresponding filters. The filtering affects both the map display and the feature browsing list. |
| 59 | + |
| 60 | +Filters do not stay saved when the app is restarted. |
| 61 | + |
| 62 | +Here is an example of how filtering works: |
| 63 | + |
| 64 | +1. Tap the **More** button to open **Filters** defined in the project |
| 65 | + |
| 66 | + Filtering has to be enabled in the [QGIS project](#enable-and-define-filtering-in-qgis), otherwise this option is not displayed. |
| 67 | +  |
| 68 | + |
| 69 | +2. Enter or select values in the filters. You can use more filters at once. |
| 70 | + |
| 71 | + Here, we will use a *Single select* filter on the *trees* layer and select a *tree species* value from the list. |
| 72 | + |
| 73 | + Tap on the **Apply filters** button to confirm the filtering. |
| 74 | +  |
| 75 | + |
| 76 | +3. With active filters, only features that match the criteria are displayed on the map as well as when [browsing features](../layers/#layers-legend-and-features). |
| 77 | + |
| 78 | + You can use the active **Filters** button to quickly access filters. |
| 79 | +  |
0 commit comments