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?
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:57atributes(...)returns a value map, not an array - so adding [index] does not work. We also have no clue whatFIELDstands 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:00attribute( 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:33exclude page from exportI 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