4

From a layer1 to which I apply a filter ("field1"='value') in the provider feature filter dialog window, I would like to reuse this Expression, or just the attribute 'value' in another layer2 Filter dialog window.

So, if I change the value of the filter 'value' in layer1, the value of the filter in layer2 is also changed.

My aim is to avoid the copy/paste action of the 'value' from one layer to another layer in the filter dialog window.

Project description:

  1. In this case I have a project with only one layer (layer1) that I use for basic digitizing/capturing data.
  2. I duplicate this layer rename it (layer2) and change the style.
  3. I need the duplication of layers to create two different visualizations of the same data in the Layout.
  4. In the Layout, I use two themes created with Manage Map Themes.

Here you can see the filter from layer1:

enter image description here

Here you can see the filter from layer2:

enter image description here

As you can see in the layer2 filter, the value is a fake value. I only put the text of what I would like to update from layer1.

6
  • Sorry, question is confusing. Filter where? Attribute table? What does FIELD1="VALUE" represent? What is FIELD1? A fieldname? A string? And value is a fieldname? Can you post a screenshot?
    – Babel
    Nov 2, 2023 at 19:55
  • Sorry. I add more details answering your questions: Filter on Query Builder Expression is "FIELD1" = 'VALUE'. "FIELD1" means the name from the attribute table. "VALUE" means the value for which I filter the records Format value is a String I add a screenshot in my question
    – Acperience
    Nov 2, 2023 at 20:25
  • So you ask about provider filter (you access it from the layer properties, not from the attribute table, right?). I'm not sure but I don't think it's possible to access values from other layers. Maybe you should tell us a bit more about your use case and why you want to do that to see what other options you have.
    – Babel
    Nov 2, 2023 at 21:02
  • 2
    Also be careful when using double quotes " (indicates a fieldname) and single quotes ', representing a text (string). Without any quotes, this also means a fieldname ("name" is the same as name, but different from 'name'). This adds to the confusion. Correct syntax is like "fieldname" = 'text_content_of_the_field'
    – Babel
    Nov 2, 2023 at 21:05
  • Ok. I have edit my text with the correct syntax to clarify the question
    – Acperience
    Nov 2, 2023 at 21:14

1 Answer 1

4

As you mentioned, you want the second layer to be a copy of the first one, with another style, but the same Provider Feature Filter. I don't think you can access fields from another layer there, but there are better options for what you want to achieve: use Rule-based styles.

Set the provider feature filter on your layer, then set its style to Rule-Based. You can now create two or more completely different styles for the same layer.

You can now either manually check the boxes to show/hide the different styles or use Map Themes: activate the style you want, click the eye icon in the layer panel > Add Theme.... Activate another style and repeat. Now you can switch between styles by activating the themes - also in print layouts.

A layer with a feature filter and two styles (red and blue). I defined three map themes: only red points, only blue points and both points:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.