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?

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

1 Answer 1

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')
    
3
  • 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
    Commented Apr 15, 2019 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
    Commented Apr 15, 2019 at 22:03
  • 1
    Updated with a solution for that table filter.
    – csk
    Commented Apr 16, 2019 at 16:11

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.