Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 83 additions & 24 deletions src/field/filtering/index.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
---
description: Add custom filters to sort and display only those features that you need during your field survey.
outline: deep
---

# Filtering Features in Mergin Maps Mobile App
[[toc]]

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).
Custom filters can be added to the <MobileAppNameShort /> to easily filter features displayed on the map and in the [survey layers](../layers/#browsing-features).

::: tip Feature filtering blog
![Filtering features in Mergin Maps mobile app](./mobile-filtering.gif "Filtering features in Mergin Maps mobile app")

::: tip Example project available
You can explore filtering by cloning our public project <MerginMapsProject id="documentation/filtering" />
:::

::: warning Feature filtering blog
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"/>.
:::

Expand All @@ -18,10 +25,10 @@ Filters can be enabled and defined in QGIS in **Project Properties** for GeoPack
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).
:::

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.
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.

Then, define the filter:
- **Type** - the filter type (in general, it should match the widget type of the filtered field)
- **Type** - choose the filter type (see [Filter types](#filter-types) for more details).
- **Layer** - choose from the project's GeoPackage layers
- **Field** - choose from the fields of the layer. Only fields with data types compatible with the selected filter type are offered.
- **Title** - the name of the filter, which will be displayed in the <MobileAppNameShort />
Expand All @@ -35,27 +42,10 @@ The order of filters can be changed by selecting a filter and using the **Up** a

Don't forget to save your project and synchronise changes so that you can use the filters in the <MobileAppNameShort />.


### Filter types

**Text** filter uses simple text input. Results are filtered based on the SQL expression `"field" ILIKE '%input%'`. Available for text and number field types.

**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.

**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/).

**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/).

**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 all field types. Note that Value relations with *multiple selections* are currently **not** supported.

**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 all field types. Note that Value relations with *multiple selections* are currently **not** supported.

In the <MobileAppNameShort />, the filters look like this:

![Filter types in Mergin Maps mobile app](./mobile-filter-types.webp "Filter types in Mergin Maps mobile app")

## Filtering features in the mobile app
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.
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 as well as use multiple filters on one layer. The filtering affects both the map display and the feature browsing list.

Filters do not stay saved when the app is restarted.

Expand All @@ -77,3 +67,72 @@ Here is an example of how filtering works:

You can use the active **Filters** button to quickly access filters.
![Active filter in Mergin Maps mobile app](./mobile-filtered-features.webp "Active filter in Mergin Maps mobile app")

## Filter types
Here is an overview of available filter types.

In QGIS, you choose from the following filter types: [Text](#text), [Number](#number), [Date](#date), [Checkbox](#checkbox), [Single select](#single-select), [Multi select](#multi-select).

![QGIS filter types](./qgis-filter-types.webp "QGIS filter types")

In the <MobileAppNameShort />, the respective filters look like this:
![Mergin Maps mobile app filters](./mobile-filters.webp "Mergin Maps mobile app filters")

### Text

The text filter can be used to find all features where the selected field contains the entered text.

Type in a word, a part of the word or a number into the filter and **Apply filters** to see the results.

Available for text and number field types.

![Mergin Maps mobile app Text filter](./mobile-filter-text.webp "Mergin Maps mobile app Text filter")

This filter uses the same logic as the SQL expression `"field" ILIKE '%input%'`.

### Number
The number filter provides *from* and *to* number inputs.

Available for text and number field types.

![Mergin Maps mobile app Number filter](./mobile-filter-number.webp "Mergin Maps mobile app Number filter")

This filter uses the same logic as the SQL expression `"field" >= 'input_from' AND "field" <= 'input_to'`.

### Date
The date filter provides *from* and *to* date calendar inputs.

Available for date field types configured with the [Date and time widget](../../layer/date-time/).

![Mergin Maps mobile app Date filter](./mobile-filter-date.webp "Mergin Maps mobile app Date filter")

This filter uses the same logic as the SQL expression `"field" >= 'input_from' AND "field" <= 'input_to'`.

### Checkbox
The checkbox filter provides a toggle between *all*, *true* and *false* values. Available for Boolean, text and integer field types configured with the [Checkbox widget](../../layer/checkbox/).

![Mergin Maps mobile app Checkbox filter](./mobile-filter-checkbox.webp "Mergin Maps mobile app Checkbox filter")

This filter uses the same logic as the SQL expression `"field" == 'input'`.

### Single select
The single select filter provides a drop-down menu of field values. One value can be selected at once.

Available for all field types. For text, number, date and Boolean field types generates a list of used values.

![Mergin Maps mobile app Single select filter](./mobile-filter-single-select.webp "Mergin Maps mobile app Single select filter")

This filter uses the same logic as the SQL expression `"field" == 'input'`.

Note that Value relations with *multiple selections* are currently **not** supported.

### Multi select
The multi select filter provides a drop-down menu of field values. Multiple values can be selected at once.

Available for all field types. For text, number, date and Boolean field types generates a list of used values.

![Mergin Maps mobile app Multi select filter](./mobile-filter-multi-select.webp "Mergin Maps mobile app Multi select filter")

This filter uses the same logic as the SQL expression `"field" IN ('input')`.

Note that Value relations with *multiple selections* are currently **not** supported.
Binary file added src/field/filtering/mobile-filter-checkbox.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/field/filtering/mobile-filter-checkbox.xcf
Binary file not shown.
Binary file added src/field/filtering/mobile-filter-date.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/field/filtering/mobile-filter-date.xcf
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added src/field/filtering/mobile-filter-number.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/field/filtering/mobile-filter-number.xcf
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added src/field/filtering/mobile-filter-text.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/field/filtering/mobile-filter-text.xcf
Binary file not shown.
Binary file removed src/field/filtering/mobile-filter-types.webp
Binary file not shown.
Binary file removed src/field/filtering/mobile-filter-types.xcf
Binary file not shown.
Binary file modified src/field/filtering/mobile-filtering.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/field/filtering/mobile-filters.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/field/filtering/mobile-filters.xcf
Binary file not shown.
Binary file added src/field/filtering/qgis-filter-types.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/field/filtering/qgis-filter-types.xcf
Binary file not shown.
Loading