I am looking for an expression to get_feature with two values from two different fields.

At its core is the question: How can I transform a chain of values which define a point into a valid geometry expression? For example for Point B:

?? geometry ("obj_art" = 'Ansicht' and  "ptnr" = 'B')   ??

Kasper has given us the answer to the question how a geometry can be defined over several values. You can use the aggregate ( ) expression. On the last position (filter:=), an arbitrarily long chain of values or conditions can be placed. The expression is unfortunately not self explanatory, but there are plenty of examples.

aggregate(layer:=' ', aggregate:=' ', expression:= , 
filter:="prof_nr"= @atlas_pagename and "obj_art"='Ansicht' and "ptnr" ='B' and so on and so on  )

My Goal is to plot archaeological profiles via QGIS Atlas. Therefore I want to use Point A and Point B to filter page name. enter image description here As coverage layer I have a point layer in which point A and B are located. Both points have the same value in field “prof_nr” so that is page name. Both points are defined by two other values from two different fields (Image 1).

My approach is to make_line out of both points, so that I always get only one Atlas feature per archaeological profile on which the map zooms in the middle. Both points can be easily called by CASE WHEN but with the expression I do not succeed in creating a line (Image 1)

CASE WHEN "obj_art" = 'Ansicht' and  "ptnr" = 'A' or  "obj_art" ='Ansicht' and  "ptnr" = 'B' THEN "prof_nr"  END

Therefore I select only point A for page name and moved the make_line to the extents of the map (Image2, 3) enter image description here enter image description here

            get_feature('E_Point', 'ptnr','B')      

Here I can connect both points with make_line, but with get_feature I can only assign a value from one field but to define the point I need two values from two fields for each point.

Does anyone have a solution?

  • Sharing a project with sample data could help understanding the problem. Otherwise, one has first to try re-creating a similar project what quite takes some time that would be better spent on finding a solution.
    – Babel
    Commented Feb 5, 2023 at 14:46
  • 1
    Why not use the line generated from the point as your atlas layer? Or even group the points in a multipoint geometry?
    – Al rl
    Commented Feb 5, 2023 at 14:49
  • In my coverage layer there are other points to which the filter 'E_Point', 'ptnr','B' applies. Therefore I need to add another value from another field to specify the filter (and the point).
    – Janko
    Commented Feb 5, 2023 at 15:16
  • Have a look at the 'aggregate' function and it's examples, you will be able to get your feature thanks to an appropriate filter (ptnr = B and prof_nr = whatever needed)
    – Kasper
    Commented Feb 5, 2023 at 15:56
  • Tried a lot with something like: aggregate (layer:='E_Point',aggregate:='collect',expression:=bounds($geometry),filter:= "ptnr" ='B'and"obj_art"='Ansicht'). But its always a geometrie: emtpy, NULL or in this case a geometry: Multipolygon?
    – Janko
    Commented Feb 5, 2023 at 17:37

1 Answer 1


The Solution ist to override the x_Extents of the map!

For x_min I call point A

aggregate (layer:='E_Point',aggregate:='collect',
,filter:="prof_nr"= @atlas_pagename and "obj_art"='Ansicht' and "ptnr" ='A' )

For x_max I call point B

aggregate (layer:='E_Point',aggregate:='collect',
,filter:="prof_nr"= @atlas_pagename and "obj_art"='Ansicht' and "ptnr" ='B' )

Filter for pagename is to call Point A (or Point B, it doesn't matter)

CASE WHEN "obj_art" = 'Ansicht' and  "ptnr" = 'A' THEN   "prof_nr" END

That's it

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.