1

I am running an atlas in QGIS, using the @layout_page to dynamically access data in a second layer, iterating with @layout_page value. And I am trying to "exclude from export" features that have a value of 0 in a certain field:
aggregate('mydatatable','sum',attributes(get_feature('the_second_layer','id',@layout_page))['FIELD']) > 0

But when exporting atlas, @layout_page seems to return a value that already excludes the empty pages.

Let's say I have values 1,2,0,0,2, so I would need pages one, two and five to be shown. But as the third, and fourth pages are excluded from export, then my approach is returning features one, two and three.

How can I get an "absolute" value of @layout_page (considering all the pages, even the excluded in export ones) instead of "dynamic" @layout_page value?

Kadir Şahbaz
  • 76,800
  • 56
  • 247
  • 389
Jose H
  • 41
  • 4
  • 1
    Sorry, your question is unclear. Can you share the project + data for testing and to see your data structure? Without that, we have to rebuild a project based on some vague information and it will probably not match your use case. – Babel Aug 27 '22 at 10:18
  • 1
    What is your QGIS version? Which layer do you use as coverage layer for your atlas? Where exactly do you apply the expression? Where do you exclude from export? What layers with which attributes do you have and how are they related? Why do you aggregate/sum an attribute: will the sum not always be more then 0 (aggregating over all fields)? What do you want to ultimately achieve? A lot of questions - without these information, it's difficult to give any advice. – Babel Aug 27 '22 at 10:57
  • atributes(...) returns a value map, not an array - so adding [index] does not work. We also have no clue what FIELD stands for in your expression. So as told earlier: best would be to make available project with sample data to be able to understand the idea. – Babel Aug 27 '22 at 11:00
  • Hi @Babel, thanks for your help. Actually I have reviewed the structure of my data, and I am finally using attribute( get_feature_by_id('table',@atlas_pagename), attribute(get_feature_by_id ('second_table',@layout_page-1),'myfield') ). Actually your post from 2020 (https://gis.stackexchange.com/questions/381800/how-to-get-attribute-values-of-another-layer-with-qgis-expressions) and the answers from @MrXsquared were very helpful. – Jose H Aug 27 '22 at 22:33
  • About the exclude page from export I am doing it through the atlas user interface, in page properties. But unfortunately after several tests I understand that page numbering is dynamic, so if a page is excluded, then it is not added in @layout_page. I will try a different approach with pyqgis. Thanks @Babel . – Jose H Aug 27 '22 at 22:35

0 Answers0