In QGIS 3.12.2. I created a virtual layer to use for the sort-order in a print layout as described here: Sort attribute table by hidden column in Print Composer

That works, but I have a problem with the geometry. The virtual layer does not seem to have a geometry and I was not able to create one in the edit field of the virtual layer (I tried set automatically as well as defining a point-geometry and the CRS of the original layer it is created from). In the layers panel, the virtual layer shows with a point-rendering symbol, however does not show on the map. Also zooming to the layer has no effect.

I need the geometry to insert the page-number of the atlas sheet each point apears on, see: QGIS expression to access page-number of atlas for certain features

Here is what I tried, based on the first link above:

enter image description here


1 Answer 1


You need to include the geometry column from the source layer

select name, pop_tot, pop_ordering, geometry
from towns
where pop_tot<12000
order by pop_ordering
  • OK, that works, now the geometry appears. However, the selection does not seem to work as it should, at least not if I add an attribute tabel to the print composer. When I set the virtual layer as source, all attributes from the original layer (not only the selected ones) appear and the sort-order defined in the virtual layer is completely ignored.
    – Babel
    Commented May 23, 2020 at 15:56

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.