Also as a variation of an answer to How to count points within the current Print composer atlas feature in QGIS 2.8? , from QGIS 2.16 onwards you can list attributes intersecting an atlas feature within the Expression Editor, using the
aggregate() function with the
concatenate calculation and
within($geometry,@atlas_geometry) as the filter.
The full syntax in your text label for a comma-delimited list would be
within($geometry,@atlas_geometry), ',') %]
Replace the ',' with whatever you wish to separate the values with. Note it may not appear correctly in the preview at the bottom of the Expression Editor, but does work otherwise.
This will concatenate all the values for the specified attribute in your specified layer, but only if the feature geometry is within the atlas geometry.
[% %] is required to make the expression work. And note the quotation marks - you must use double quotes for the attribute name.
As a bonus you can add on to the above filter, e.g.
within($geometry,@atlas_geometry) AND "PPP" > 50000 for countries within the atlas geometry, where the GDP per capita is over 50k.
QGIS 3.0 bonus: By wrapping the above expression in some of the new array functions available in QGIS 3 (2.99), you can easily split up your list of attributes - say only the first 3 attributes in one text box, then the next 3 attributes in another. (apologies for the poor formatting)
This takes your concatenated list of attributes as above, converts it into an array specifying the delimiter you used with
string_to_array(), extracts the first 20 from the list (here shown as
19 because arrays start at 0) with
array_slice(), then spits that back out as a string with
Note: I don't yet know how to sort the array.
Also, I haven't been able to use
array_agg() within the
aggregate() function to cut down on the number of steps, since
array_agg() doesn't seem to realise it's looking for an attribute within the layer specified by