You have to provide your own QAbstractProxyModel implementation that performs such calculations. For performance reasons you probably want to calculate aggregates on request and cache them in the proxy model instead of recalculating them each time someone asks for data.
Bookmarks