1

I have an attribute table in a page in one frame with a certain dimension (width/height). The content of this table is not enough to fill the height of the frame and is aligned to the top. Is any of this possible?

1) keeping the fixed dimensions of the frame, align the content of the table to the bottom of the frame?

2) having the frame height automatically calculated based on the content? (i.e. based on the number of rows?)


The table is filtered using the expression "ref_pln" = attribute(@atlas_feature,'ref_pln'), so the table displays rows if the value of their "ref_pln" attribute is equal to the value of the "ref_pln" being evaluated by the atlas.

How can I fill "table count" in the atlas using this filter?

  • How is the content of the attribute table item calculated? Is it based on an atlas? – csk Apr 15 at 16:58
  • Yes. The content comes from a CSV layer which gets filtered by the current atlas item. – BMM Apr 15 at 18:29
1

How to make frame height automatically calculated based on the number of table rows

  1. Add a field to the atlas layer, "table_count". Populate this field with the number of CSV table rows that will be displayed on the table in the print composer.

    • If the table is filtered by "show only features intersecting atlas feature,"

    enter image description here

    Install the RefFunctions plugin to enable the intersecting_geom_count() function. Use this expression in the field calculator to fill "table_count":

     intersecting_geom_count('CSVlayer') 
    
    • If the table is filtered by some other way, use an expression based on the table filter. Eg, with the table filter "ref_pln" = attribute(@atlas_feature,'ref_pln'), use the aggregate count function to count the number of table rows where the ref_pln value in the table matches the ref_pln value in the atlas layer:

      aggregate( 'CSVlayer', 'count', "ref_pln","ref_pln" = attribute(@parent,'ref_pln'))
      
  2. Then set the table height using data-defined settings.

    enter image description here

    Use an expression that multiplies the height of each row by the number of rows in the table. Eg if the rows are each 4mm tall:

    4 * attribute(@atlas_feature , 'table_count')
    
  • Thanks for helping. I understand the logic but still not following. The table is filtered using the expression "ref_pln" = attribute(@atlas_feature,'ref_pln') --- table displays rows if the value of their "ref_pln" attribute is equal to the value of the "ref_pln" being evaluated by the atlas. How can I fill "table count" in the atlas using this filter? Thanks – BMM Apr 15 at 21:47
  • I can't edit so I'll post a new comment. Logic is understood and I'm having it working perfectly with hardcoded values in "table_count". Just need to figure out how to automatically calculate this value for each "ref_pln". – BMM Apr 15 at 22:03
  • 1
    Updated with a solution for that table filter. – csk Apr 16 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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