[Qgis-user] Cross layer filtering

Adam Nielsen a.nielsen at shikadi.net
Thu Mar 28 18:20:01 PDT 2024


> I've been filtering a layer by adding a virtual column populated with
> is_selected() and then creating a virtual layer from it using the
> filter: WHERE virtualField = 1
> 
> This is working well and allows you to have a copy of the layer that
> only shows the selected records when you are creating a layout.

What's your use case for this?  I just wonder whether there is an
alternative that might be easier?

For example if you're always selecting the same set of features, you
could add a category/classification column and then filter based on
that.

> I now need to bring in an associated layer, but I can't find a
> reliable way to cross layer filter because QGIS just hangs for ages
> and crashes.

I have found that QGIS can be extremely slow sometimes when joining
tables and can often crash, so if there's a solution that can avoid
this you might find it more robust.

> I've searched around and can see a lot of people talk about making
> the database do the work but of course it can't if you are trying to
> use a selection filter.

So there's definitely no way you can classify your data such that you
don't need to use a selection filter?

> What is the most reliable way of setting up a filter based on a join
> because QGIS tells me that I must use a virtual layer and even
> creates it for me; but then it just hangs and crashes.

I suppose you could export the virtual selection layer (or even forget
the layer and just use "export selected features") and put those in a
real database table, which you then link off instead?  It would be a
more laborious process having to do an export each time you wish to
select different features but it might at least allow the workflow to
complete.

Cheers,
Adam.


More information about the QGIS-User mailing list