qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.35k stars 2.98k forks source link

Allow to make permanent a filter created in the table of attributes with the expression builder #46541

Open gioman opened 2 years ago

gioman commented 2 years ago

Feature description

Filtering a data source with the query builder is usually enough, but functions available are limited (yes, one can use the provider functions, but is not very friendly for common users).

On the other hand we can filter a table/layer temporarily (because as soon as one closes the table the filter is gone) from the table of attributes with the QGIS expression builder, so seems logic to have an option to make such filters "permanent" in the context of a QGIS project (and filter also the geometries of course).

Additional context

No response

m-kuhn commented 2 years ago

The main challenge here is that layer filters and attribute table filters (expressions) are different sql dialects.

gioman commented 2 years ago

The main challenge here is that layer filters and attribute table filters (expressions) are different sql dialects.

@m-kuhn I wrote filter as the one created by the query builder (which filters the source) but it could be something more on the QGIS side, for example:

With rule based symbology you can "filter"geometries with the expression builder, but records in the attribute table won't be filtered.

In the attribute table you can use expression to filter attributes (albeit in a temporary way), but geometries won't.

The idea would be to use a an expression to "filter" both, as much the filter in the rule based renderer. In fact it could even be an option in the rule based renderer filter like "filter also attributes".

m-kuhn commented 2 years ago

Thoughts:

nyalldawson commented 2 years ago

@m-kuhn

we could add expressions as supported syntax for layer filters (query builder). You would have two options in the query builder: "native provider filter" or "expression". If the goal is to filter features everywhere (canvas, attribute table, field calculator, processing, ...) this is the thing that we need.

I think ultimately this is the way we should go. There's been a lot of related requests, and we'd gain a lot of flexibility through this (e.g. filters which use expression variables!)

We could have a context menu action in the layer tree to "open attribute table for visible features" which would open a filtered attribute table for only visible features. It needs to be discussed if visible means "current canvas extent" also or just "symbology rule".

This is already there -- From Layer -> Filter Attribute Table -> Open Attribute Table (Visible Features)