3

Is it possible to display a summary of statistics from a certain attribute within a feature class within the print composer using an sql statement. I have an shapefile "projects" with a number of features and attributes such as location, author, value, etc etc. I would like to provide a simple table or text box within the composer that displays statistics based on a certain attribute. For example i would like to show the sum of all the "value" attributes for a given "author". something like

Sum('projects'.'value') where 'author'=XXX

Therefore, if i change some of the attributes in the table, such as the value of a project or author of a project, the text in the composer would update automatically.

Ideally i would like a composer that shows on the map all of the features (coloured by author for example) and then a summary table for each author with a feature count, total value, and any other summaries etc.

4

You are going to have this in the next version (8th july)

Changelog for version: 2.16.0 ....... Feature: Aggregate support for expressions** QGIS 2.16 adds support for a several types of aggregates to the expression engine. These include: Aggregates within the current layer, eg sum("passengers") Supports sub expressions (ie sum("passengers"/2) ), group by ( sum("passengers", group_by:="line_segment") ), and optional filters ( sum("passengers", filter:= "station_class" > 3 ) ) Relational aggregates, which calculate an aggregate over all matching child features from a relation, eg relation_aggregate( 'my_relation', 'mean', "some_child_field" ) A summary aggregate function, for calculating aggregates on other layers. Eg aggregate('rail_station_layer','sum',"passengers"). The summary aggregate function supports an optional filter, making it possible to calculate things like: aggregate('rail_stations','sum',"passengers", intersects(@atlas_geometry, $geometry ) ) for calculating the total number of passengers for the stations inside the current atlas feature In all cases the calculations are cached inside the expression context, so they only need to be calculated once for each set of expression evaluations. ......

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.